:root {
    --radius: 12px;
    --shadow: 0px 2px 20px rgba(0,0,0,0.1);
    --muted: var(--secondary-label);
    --surface: var(--bg);
    --brand-dark: #565c62;
}

main {
    line-height: 1.6;
    margin-top: 35px;
    max-width: calc(var(--measure) + 2.5rem); /* measure + side padding */
    margin-left: auto;
    margin-right: auto;
    padding: 0 1.25rem;
}
main li {
    line-height: 1.5;
    margin-bottom: .5em; 
}

main h1,
main h2,
main h3 {
    line-height: 1.3;
}

.page-title {
    margin-bottom: .35em;
}

table {
    border-collapse: collapse;
    width: 100%;
    margin: auto;
    background-color: var(--surface);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    overflow: hidden; 
}
th, td {
    border: 0.5px solid var(--separator);
    padding: 12px;
    text-align: center;
}
th {
    background-color: #565c62;
    color: white;
}
tr:nth-child(even) {
    background-color: var(--grouped-bg);
}

.table-title {
    text-align: center;
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 12px;
}

figure { text-align: center; margin: 20px auto; }
figure img {
    display: block;
    width: auto;       /* fill the measure, but keep tall photos within the screen */
    max-width: 100%;
    max-height: 75vh;
    height: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-left: auto;
    margin-right: auto;
}
figure figcaption {
    margin-top: .5rem;
    color: var(--muted);
    font-size: .95rem;
}

/* Breaks out of the text column to --wide, centered, never wider than the viewport. */
figure img.figure-large {
    --w: min(var(--wide), 100vw - 2.5rem);
    width: var(--w);
    max-width: none;
    margin-left: calc((100% - var(--w)) / 2);
    margin-right: calc((100% - var(--w)) / 2);
}

blockquote {
  background: var(--grouped-bg);
  border-left: 4px solid var(--separator);
  margin: 1.5em 10px;
  padding: 0.5em 10px;
}
blockquote:before {
  color: #ccc;
  /* content: open-quote; */
  font-size: 4em;
  line-height: 0.1em;
  margin-right: 0.25em;
  vertical-align: -0.4em;
}
blockquote p {
  display: inline;
}

blockquote .source{
  display:block;
  color: var(--label);
  font-style: normal;
  font-weight: bold;
  margin-top:1em;
}

details {
  border: 0.5px solid var(--separator);
  border-radius: 10px;
  padding: 0.5em 0.5em 0;
}
details.callout[open] {   
    padding: 0.5em; 
}
details[open] summary {
  border-bottom: 0.5px solid var(--separator);
  margin-bottom: 0.5em;
}
summary {
  font-weight: bold;
  margin: -0.5em -0.5em 0;
  padding: 0.5em;
}

.page-date{
  color: var(--secondary-label);

}

.text-block {
  border-left: .3rem solid #7b96d2;
  background: var(--grouped-bg);
  padding: .9rem 1rem;
  margin: 0; /* inside details, so no extra gap */
}
.text-block dl { display: grid; grid-template-columns: max-content 1fr; gap: .35rem .75rem; margin: 0; }
.text-block dt { font-weight: 600; }
.text-block dd { margin: 0; }

.ref {
  position: relative;
  cursor: help;
}

.ref::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  display: inline-block;
  width: min(16rem, 90vw);
  white-space: normal;           /* allow wrapping */
  overflow-wrap: break-word;     /* break long words/URLs */

  /* Styling */
  background: #222;
  color: #fff;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  line-height: 1.3;
  text-align: left;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  z-index: 10;

  /* Show/hide */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease-in-out;
}

.ref:hover::after {
  opacity: 1;
}

.text-block pre {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}


mjx-container {
    overflow-x: auto;
    max-width: 100%;
}

/* Mobile tweaks */
@media (max-width: 768px) {
    main {
        max-width: 100%;
        margin-top: 28px;
        padding: 0 1.1rem;
    }
    .page-title {
        font-size: 1.9rem;
        line-height: 1.32;
    }
    table {
        width: 100%;
        table-layout: fixed;     /* makes colgroup widths “stick” */
        display: block;          /* enables overflow scrolling */
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    thead, tbody { display: table; width: 99%; table-layout: fixed; }
    th, td {
        font-size: clamp(0.78rem, 2.8vw, 0.95rem);
        padding: clamp(6px, 1.6vw, 10px);
        line-height: 1.25;
        white-space: normal;     /* ensure wrapping is allowed */
        overflow-wrap: anywhere; /* breaks long tokens only when needed */
    }
    
    figure img.figure-large { --w: 100%; }
    .text-block {
        padding: 1rem 0.9rem;
    }
    .text-block pre {
        font-size: .95rem;
    }

    main ul,
    main ol {
        padding-left: 1.1rem;
        margin-left: 0;
        list-style-position: outside;
    }
    main li {
        margin-bottom: 0.45rem; /* slightly tighter */
    }
}
