html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden; /* Prevent accidental scrollbars on the page itself */
}


body {
    font-family: system-ui, Roboto, sans-serif ;
    padding: 0.5rem;
    box-sizing: border-box; /* Include padding in the height calculation */
    display: flex;
    flex-direction: column;
    min-width: 750px;
}

.story {
    height: 100%;
    margin: 0 0 0.5rem 0; 
    display: flex ;
    flex-direction: column;
    font-family: system-ui, Roboto, sans-serif;
}

#transcript-header {
    display: flex;
    justify-content: flex-end; 
    align-items: center;
    gap: 1rem; /* This creates the space between the search and share buttons */
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #ccc;
    background-color: #f5f5f5;
}

/* A generic class for buttons in the header */
.header-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem; /* Space between icon and text */
    background-color: transparent;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 0.3rem 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
}
.header-button:hover {
    background-color: #f0f0f0;
}
.header-button svg {
    width: 18px;
    height: 18px;
    fill: #555;
}

#search-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Style for the search next/prev buttons */
#search-prev-btn, #search-next-btn {
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    border-radius: 4px;
}
#search-prev-btn:hover, #search-next-btn:hover {
    background-color: #e0e0e0;
}
#search-prev-btn svg, #search-next-btn svg {
    width: 24px;
    height: 24px;
    fill: #333;
}

.story #story-controls {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border-radius: 6px;
  border: 1px solid #ddd;
}

.story #split-container {
  display: flex;
  flex-direction: row;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
  flex-grow: 1;
  /* height: var(--player-height, 420px); */
  min-height: 0px;
  /* max-height: 90vh; */
  width: 100%;
  /* resize: vertical; */
  overflow: auto;
}

.story .gutter {
  background-color: #eee;
  flex: 0 0 10px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.2s;
}
.story .gutter.gutter-horizontal {
  cursor: col-resize;
}
.story .gutter:hover {
  background: #ddd;
}
.story .gutter-grabber {
  width: 8px;
  height: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  pointer-events: none;
}
.story .gutter-grabber-dot {
  width: 6px;
  height: 6px;
  border-radius: 3px;
  background: #aaa;
}

.story #video-pane {
  background: #111;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 200px;
  height: 100%;
}
.story #video {
  width: 100%;
  height: 100%;
}
.story #video iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.story #transcript {
  font-size: 0.8rem;
  flex: 1 1 0;
  padding: 1rem;
  box-sizing: border-box;
  height: 100%;
  background: #fff;
  overflow-y: auto;
  overflow-x: hidden;
  transition: all 0.25s;
}

.story #transcript.storyboard {
  height: calc(100% - 40px);
  column-width: 250px;
  column-gap: 1rem;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: normal;
}

.story #transcript.storyboard h2[data-start]:not(:first-child) {
  break-before: column; 
  break-inside: avoid;
}

.story #transcript .active {
  background: #fff3ba;
  border-radius: 6px;
  transition: background 0.18s;
}
.story #transcript .hovered:not(.active) {
  background: #e6f3ff;
  border-radius: 6px;
  transition: background 0.18s;
}
.story #transcript .active.hovered {
  background: #ffe065;
}

/* Thumbnails: scale to fit column, keep aspect */
.story #transcript img[data-start] {
  display: block;
  max-width: 100%;
  width: 100%;
  height: auto;
  margin: 1em 0;
  border-radius: 8px;
  box-shadow: 0 1px 8px 0 rgba(0, 0, 0, 0.03);
  transition: outline 0.18s, box-shadow 0.18s, filter 0.18s;
}

.story #transcript-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 300px;
  background: #fafafa;
  box-sizing: border-box;
  border-left: 1px solid #ddd;
  position: relative;
}

#title-headings {
  position: relative;
  height: 40px;
  background: transparent;
  overflow: hidden;
  width: 100%;
  z-index: 10;
}

.floating-title {
  position: absolute;
  top: 0;
  height: 40px;
  color: #fff;
  display: block;
  align-items: center;
  font-size: 1.04rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding-left: 1em;
  padding-right: 1em;
  border: 2px solid #fff;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  box-sizing: border-box;
  opacity: 0.97;
  transition: background 0.18s, border-color 0.18s;
  line-height: 40px; /* Set line-height equal to the element's height to vertically center the text */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  pointer-events: auto;
  z-index: 11;
}

/*
  This new rule makes the active image's outline color match the
  color defined by the section's 'color-*' class.
  Colors should be the same as preceeding definition for section titles
*/
.color-0 {
  --section-color: #612461;
}
.color-1 {
  --section-color: #40558c;
}
.color-2 {
  --section-color: #4f8d88;
}
.color-3 {
  --section-color: #c55d1c;
}
.color-4 {
  --section-color: #459dce;
}
.color-5 {
  --section-color: #b84746;
}
.color-6 {
  --section-color: #9c27b0;
}
.color-7 {
  --section-color: #827717;
}

img.image-active[class*="color-"] {
  outline: 3px solid var(--section-color);
  outline-offset: -2px;

  box-shadow: 0 0 16px 0 var(--section-color);
  filter: brightness(1.1) saturate(1.3);
  z-index: 1;
}

.floating-title[class*="color-"] {
  background-color: var(--section-color);
}

#search-input {
  padding: 0.3rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  width: 400px;
  font-size: 1.1rem;
}

#search-results-count {
  font-size: 0.8rem;
  color: #666;
}

/* Style for paragraphs that match the search */
#transcript p.search-match {
  background-color: #ffd700; /* A gold highlight for matches */
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

#search-clear-btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: #888;
  padding: 0 0.3rem;
}
#search-clear-btn:hover {
  color: #000;
}

#transcript mark.search-highlight {
  background: yellow;
  color: inherit;
}

#transcript mark.current-search-highlight {
  background: orange;
  color: black;
  border-radius: 2px;
  padding: 0 2px;
}

#share-timestamp-btn.copied {
  color: #4caf50; /* A success green */
  font-weight: bold;
}

.floating-title.active-title {
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

/* Ensure the titles inside don't wrap and are aligned. */

#companion-title-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 40px; /* Must match the #transcript-header height */
  z-index: 20;

  line-height: 40px; /* Set line-height equal to the element's height to vertically center the text */

  /* Styling to match the floating titles */
  color: white;
  font-weight: bold;
  padding: 0 1rem;

  /* These three properties can now work correctly */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

#section-nav-container {
  display: flex;
  align-items: center;
  gap: 0.4em;
  margin-right: 1em; /* Optional: tweak as needed for spacing */
}

#section-nav-container label {
  font-size: 1rem;
  font-weight: 300;
  margin-right: 0.3em;
}

#section-nav-container > div {
  position: relative;
}

#section-nav {
  font-size: 1rem;
  font-weight: 400;
  padding: 0.28em 2em 0.28em 0.8em;
  border-radius: 4px;
  border: 1px solid #ccc;
  background: #fff;
  font-family: inherit;
  cursor: pointer;
  min-width: 110px; /* Optional: Ensures select doesn't shrink too small */
}

#section-nav:focus {
  outline: 2px solid #6699ff;
}

#section-nav-container span {
  pointer-events: none;
  position: absolute;
  top: 50%;
  right: 0.6em;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  height: 100%;
}

#section-nav-container span svg {
  display: block;
}

/* Header - Page title and description */

.app-header {
  background: #fafbfc;
  border-bottom: 1.5px solid #eee;
  box-shadow: 0 2px 8px rgba(40,60,80,0.03);
  padding: 8px 1.8em 0.7em 1.0em;
  position: relative;
}
.header-main {
  display: flex;
  align-items: center;
  gap: 1.1em;
}
.logo-link {
  margin-right: 1em;
  display: flex;
  align-items: center;
}
.logo-img {
  width: 38px;
  height: 38px;
  display: block;
}
.header-titles {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.main-title {
  font-size: 1.5rem;
  font-weight: 500;
  margin: 0 0 0.18em 0;
  color: #1b2330;
  letter-spacing: 0.01em;
}
.desc-toggle {
  font-size: 1em;
  background: none;
  border: none;
  color: #3567f8;
  display: flex;
  align-items: center;
  gap: 0.3em;
  cursor: pointer;
  transition: color 0.15s;
  padding: 0;
  margin-left: 0;
}
.desc-toggle:hover {
  color: #163f84;
}
.desc-panel {
  background: #f5f8fd;
  color: #1d2738;
  font-size: 1.05em;
  margin: 1em 0 0 56px; /* space for logo */
  padding: 1.2em 1.4em;
  border-radius: 8px;
  box-shadow: 0 1px 8px rgba(50, 70, 120, 0.05);
  max-width: 700px;
  line-height: 1.65;
}
.header-accent {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, #3460f7 0%, #20b486 100%);
  border-radius: 0 0 5px 5px;
}
@media (max-width: 800px) {
  .app-header { padding: 0.7em 0.7em 0.6em 0.7em; }
  .header-main { gap: 0.7em; }
  .main-title { font-size: 1.13rem; }
  .desc-panel { margin-left: 46px; padding: 0.7em 1em; }
}

.story.loading {
  visibility: hidden;
  /* Or optionally: */
  /* opacity: 0; */
}

#transcript-pane:focus {
  outline: none;
  box-shadow: none;
}