:root {
  --main-bg: #121212;
  --text-color: #EAEAEA;
  --cloud-color: #3b3939;
  --title-color: #00aaff;
  --link-color: #00aaff;
  --border-color: #333;
  --button-text: #ccc;
  --button-hover-bg: #222;
  --button-active-bg: rgba(0, 170, 255, 0.1);
  --cloud-font-size: 16pt;
  --cloud-blur: 0.5px;
}

body {
  background-color: var(--main-bg);
  color: var(--text-color);
  font-family: 'Courier New', Courier, monospace;
  margin: 0;
  padding: 2rem;
  animation: fadeIn 1s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

#page-container {
  position: relative; /* Establish stacking context */
  z-index: 1; /* Lift this container above the background */
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 2rem;
  width: 100%;
  padding-top: 5vh;
  pointer-events: none;
}

#unified-view {
  position: relative;
  z-index: 0;
  width: 100%;
  max-width: 800px;
  border: 1px solid var(--border-color);
  background-color: var(--unified-view-bg);
  pointer-events: auto;
}

#view-toggle, #fragment-container, #trace-container {
  pointer-events: auto;
}

#view-toggle {
  display: flex;
  border-bottom: 1px solid var(--border-color);
}

.toggle-button {
  padding: 0.75rem 1.5rem;
  background-color: transparent;
  border: none;
  color: var(--button-text);
  font-family: 'Courier New', Courier, monospace;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.3s, color 0.3s;
}

.toggle-button.active {
  color: var(--text-color);
  background-color: var(--button-active-bg);
}

.toggle-button:hover:not(.active) {
  background-color: var(--button-hover-bg);
}

.hidden {
  display: none;
}

#fragment-container {
  transition: opacity 0.4s ease-in-out;
}

#fragment-container.fading-out {
  opacity: 0;
}

#fragment-container, #trace-container {
  padding: 2rem 3rem;
}

.fragment h1 {
  color: var(--title-color);
  font-size: 1.5rem;
  margin-top: 0;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

.fragment p {
  font-size: 1rem;
  line-height: 1.6;
}

.fragment-image {
  max-width: 400px;
  max-height: 400px;
  height: auto;
  width: auto;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-color);
}

.links-container a {
  color: var(--link-color);
  text-decoration: none;
  margin-right: 1.5rem;
  font-weight: bold;
  display: inline-block;
  margin-bottom: 0.5rem;
}

.links-container a:hover {
  color: var(--text-color);
  text-decoration: underline;
}

/* The Trace Styles */
#trace-container h2 {
  color: var(--button-text);
  font-size: 1.2rem;
  margin-top: 0;
}

.ariadne-thread {
  line-height: 1.8;
  font-style: italic;
  color: var(--button-text);
}

.ariadne-thread a {
  color: var(--text-color);
  text-decoration: none;
  font-weight: bold;
}

.ariadne-thread a:hover {
  color: var(--link-color);
  text-decoration: underline;
}

/* Word Cloud Styles */
#word-cloud-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0; /* Set to 0 as requested */
  overflow: hidden;
}

.cloud-word {
  position: absolute;
  color: var(--cloud-color);
  font-size: var(--cloud-font-size);
  text-decoration: none;
  opacity: 1; /* Default is now fully visible */
  filter: blur(0); /* Default is sharp */
  transition: opacity 0.3s ease-in-out, filter 0.3s ease-in-out, color 0.3s ease-in-out;
}

.cloud-word.distorted {
  opacity: 0.7;
  filter: blur(0.8px);
}

.cloud-word:hover {
  color: var(--link-color);
  opacity: 1;
  filter: blur(0);
  font-weight: bold;
  font-size: calc(var(--cloud-font-size) + 2pt);
}

/* Settings Panel Styles */
#settings-button {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background-color: var(--button-hover-bg);
  color: var(--button-text);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  font-family: 'Courier New', Courier, monospace;
  cursor: pointer;
  z-index: 10;
}

#settings-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  z-index: 20;
  display: flex;
  justify-content: center;
  align-items: center;
}

#settings-panel.hidden {
  display: none;
}

.settings-content {
  background-color: var(--main-bg);
  padding: 2rem 3rem;
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 500px;
}

.settings-content h2 {
  margin-top: 0;
  color: var(--title-color);
}

.setting {
  margin-bottom: 1.5rem;
}

.setting label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

.setting-group {
  padding: 1rem;
  border: 1px solid var(--border-color);
  margin-top: 2rem;
}

.setting-group h3 {
  margin-top: 0;
  color: var(--title-color);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.setting input[type="range"] {
  width: 100%;
}

.close-button {
  float: right;
  background: none;
  border: none;
  color: var(--button-text);
  font-size: 1.5rem;
  cursor: pointer;
}
