/* ---- Reset / Base ---- */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --sidebar-w: 280px;
  --player-h: 120px;
  --bg: #1a1a1a;
  --surface: #242424;
  --surface2: #2e2e2e;
  --accent: #c9a96e;       /* warm gold – fits the Renaissance theme */
  --accent-dim: #7a6040;
  --text: #e8e0d0;
  --text-dim: #888;
  --reading-bg: #fffef8;
  --reading-text: #2a1f0e;
  --highlight: #ffe08a;
}

html, body { height: 100%; margin: 0; font-family: Georgia, serif; background: var(--bg); color: var(--text); }

/* ---- Layout ---- */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---- Sidebar ---- */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  border-right: 1px solid #333;
  overflow: hidden;
}

#sidebar-header {
  padding: 1rem 1.2rem 0.5rem;
  border-bottom: 1px solid #333;
}

#sidebar-header h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: normal;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#toc {
  overflow-y: auto;
  flex: 1;
  padding: 0.5rem 0;
}

.toc-group { margin-bottom: 0.25rem; }

.toc-group-label {
  padding: 0.4rem 1.2rem;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  user-select: none;
}

.toc-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-group ul li button {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: 0.4rem 1.2rem;
  font-family: Georgia, serif;
  font-size: 0.8rem;
  color: var(--text);
  cursor: pointer;
  line-height: 1.4;
  transition: background 0.1s;
}

.toc-group ul li button:hover { background: var(--surface2); }

.toc-group ul li.active button {
  color: var(--accent);
  background: var(--surface2);
  border-left: 3px solid var(--accent);
  padding-left: calc(1.2rem - 3px);
}

/* ---- Content area ---- */
#content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

#welcome {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-style: italic;
}

#section-content {
  flex: 1;
  overflow-y: auto;
  padding: 2.5rem 4rem;
  background: var(--reading-bg);
  color: var(--reading-text);
  line-height: 1.8;
  font-size: 1.05rem;
}

#section-content.hidden { display: none; }

#section-content h2.section-title {
  text-align: center;
  font-weight: normal;
  font-size: 1.3rem;
  margin-bottom: 2rem;
  color: #5a3e1b;
}

/* Text blocks */
.text-block {
  margin: 0 0 0.8em;
  transition: background 0.2s;
}

.text-block.reading {
  background: var(--highlight);
  border-radius: 3px;
  padding: 0 2px;
  margin: 0 -2px 0.8em;
}

/* Image blocks */
.image-block {
  text-align: center;
  margin: 2rem 0;
}

.image-block img {
  max-width: 60%;
  max-height: 420px;
  border: 1px solid #ddd;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.image-block.reading-image {
  outline: 3px solid var(--accent);
  outline-offset: 6px;
  border-radius: 2px;
}

/* ---- Image display overlay (mid-read pop-up) ---- */
#image-display {
  position: absolute;
  top: 0; left: 0; right: 0;
  background: rgba(255,254,248,0.97);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  z-index: 10;
  transition: opacity 0.4s;
}

#image-display.hidden { display: none; }

#image-display img {
  max-height: calc(100vh - var(--player-h) - 6rem);
  max-width: 80%;
  object-fit: contain;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}

#display-caption {
  margin-top: 1rem;
  font-style: italic;
  color: #888;
  font-size: 0.9rem;
}

/* ---- Player bar ---- */
#player-bar {
  background: var(--surface);
  border-top: 1px solid #333;
  padding: 0.6rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  min-height: var(--player-h);
}

#player-bar.hidden { display: none; }

#player-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

#player-controls button {
  background: var(--surface2);
  border: 1px solid #444;
  color: var(--text);
  border-radius: 6px;
  width: 38px;
  height: 38px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, border-color 0.1s;
}

#player-controls button:hover { background: #444; border-color: var(--accent); }
#player-controls button:active { background: var(--accent-dim); }

#btn-play {
  width: 46px;
  height: 46px;
  font-size: 1.2rem;
  background: var(--accent-dim) !important;
  border-color: var(--accent) !important;
}

#player-settings {
  display: flex;
  gap: 1.2rem;
  align-items: center;
  flex-wrap: wrap;
}

#player-settings label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-dim);
}

#voice-select {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid #444;
  border-radius: 4px;
  padding: 0.2rem 0.4rem;
  font-size: 0.78rem;
  max-width: 160px;
}

input[type="range"] {
  accent-color: var(--accent);
  width: 80px;
}

#player-progress {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }

/* ---- Responsive ---- */
@media (max-width: 700px) {
  :root { --sidebar-w: 220px; }
  #section-content { padding: 1.5rem 1.2rem; }
}
