* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: #000;
  color: #fff;
  font-size: 16px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
               sans-serif;
}

body {
  display: flex;
  flex-direction: column;
}

.freetext {
  margin: 0;
  padding: 6px 10px;
  background: #111;
  font-size: 25px;
  color: #ccc;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px;
  background: #111;
  border-bottom: 1px solid #333;
}

.tab-btn {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #444;
  background: #222;
  color: #eee;
  cursor: pointer;
  font-size: 16px;
  min-width: 70px;
  text-align: center;
  user-select: none;
}

.view-mode-toggle {
  display: flex;
  padding: 6px;
  background: #1a1a1a;
  gap: 4px;
  border-bottom: 1px solid #333;
}

.mode-btn {
  flex: 1;
  padding: 8px;
  background: #222;
  border: 1px solid #444;
  color: #ccc;
  cursor: pointer;
  border-radius: 6px;
  font-size: 14px;
  user-select: none;
  transition: background 0.2s;
}

.mode-btn:hover:not(:disabled):not(.active),
.tab-btn:hover:not(.active) {
  background: #333;
}

.mode-btn.active {
  background: #f5a623;
  border-color: #f5a623;
  color: #000;
  font-weight: 600;
}

.mode-btn:disabled {
  opacity: 0.2;
  cursor: not-allowed;
  filter: grayscale(1);
}

.tab-btn.active {
  background: #f5a623;
  border-color: #f5a623;
  color: #000;
  font-weight: 600;
  cursor: grab;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #111;
  border-bottom: 1px solid #333;
  font-size: 16px;
}

.controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1 1 200px;
}

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

.controls button {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #444;
  background: #222;
  color: #eee;
  cursor: pointer;
  font-size: 16px;
  white-space: nowrap;
}

.controls button:hover {
  background: #333;
}

.viewer {
  flex: 1 1 auto;
  overflow: auto;
  position: relative;
  cursor: grab;
}

#pdfWrapper iframe {
  background: #333;
}

.pdf-search-info {
  font-size: 14px;
  color: #f5a623;
  padding: 4px 0;
}

.viewer:active {
  cursor: grabbing;
}

.viewer-inner {
  position: relative;
  width: max-content;
  height: max-content;
}

img {
  max-width: none;
  max-height: none;
  transform-origin: top left;
  display: block;
}

.notice {
  background: #111;
  border-bottom: 1px solid #333;
}

/* Desktop / default */
.freetext {
  margin: 0;
  padding: 6px 10px;
  background: #111;
  font-size: 25px;
  color: #ccc;
}

.notice-toggle {
  display: none;           /* hidden on desktop */
  width: 100%;
  padding: 6px 10px;
  background: #111;
  border: none;
  border-bottom: 1px solid #333;
  color: #ccc;
  text-align: left;
  font-size: 16px;
  cursor: pointer;
}

.notice-arrow {
  margin-left: 8px;
  font-size: 12px;
}

/* Collapsible Menu Styles */
.menu-toggle {
  display: none; /* Keep hidden on desktop */
  width: 100%;
  padding: 12px;
  background: #222;
  color: #f5a623;
  border: none;
  border-bottom: 1px solid #333;
  font-weight: bold;
  text-align: center;
  cursor: pointer;
  font-size: 16px;
}

.settings-container {
  display: block; /* Always visible on desktop */
}

.arrow {
  display: inline-block;
  margin-left: 8px;
  transition: transform 0.3s;
}

.menu-toggle.open .arrow {
  transform: rotate(180deg);
}

/* Spinner */
#loadingSpinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  margin-top: -24px;
  margin-left: -24px;
  border: 6px solid #444;
  border-top-color: #f5a623;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
  z-index: 10;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Mobile tweaks */
@media (max-width: 768px) {
  .freetext {
    font-size: 13px;
  }

  .menu-toggle {
    display: block; /* Show only on mobile */
  }

  .settings-container {
    display: none; /* Hide by default on mobile */
  }

  .settings-container.open {
    display: block; /* Show when 'open' class is added */
  }

  .tabs {
    /* Add properties or leave empty if just inherited */
  }

  .tab-btn {
    flex: 1 1 calc(33.33% - 4px);

    .controls {
      font-size: 13px;
    }

    .controls button {
      flex: 1 1 30%;
      text-align: center;
    }
  }
}
