:root {
  /* Light theme variables */
  --primary-color: #4a90e2;
  --secondary-color: #50c878;
  --background-color: #f5f5f5;
  --modal-color: rgba(0, 0, 0, 0.2);
  --text-color: #333;
  --form-background: #ffffff;
  --border-color: rgba(204, 204, 204, 0.8);
  --hover-color: rgba(114, 114, 114, 1);
  --light-grey: rgba(144, 144, 144, 0.8);
  --shadow-color: rgba(0, 0, 0, 0.1);
  --hover-bg-color: rgba(220, 220, 220, 0.3);
  --border-light: #ddd;
  --error-color: #dc2626;
  --iframe-shadow: rgba(0, 0, 0, 0.1);
  --focus-mode-bg: #ffffff;
  --spinner-bg: rgba(255, 255, 255, 0.8);
  --kbd-bg: #444;
  --kbd-hover: #555;
  --kbd-active: #333;
  --kbd-text: #ccc;
}

[data-theme="dark"] {
  --primary-color: #60a5fa;
  --secondary-color: #34d399;
  --background-color: #1a1a1a;
  --modal-color: rgba(0, 0, 0, 0.6);
  --text-color: rgb(205, 214, 209);
  --form-background: #2a2a2a;
  --border-color: rgba(75, 75, 75, 0.8);
  --hover-color: rgba(200, 200, 200, 1);
  --light-grey: rgba(180, 180, 180, 0.8);
  --shadow-color: rgba(0, 0, 0, 0.3);
  --hover-bg-color: rgba(75, 75, 75, 0.3);
  --border-light: #404040;
  --error-color: #ef4444;
  --iframe-shadow: rgba(0, 0, 0, 0.3);
  --focus-mode-bg: #1a1a1a;
  --spinner-bg: rgba(26, 26, 26, 0.8);
  --kbd-bg: #2a2a2a;
  --kbd-hover: #3a3a3a;
  --kbd-active: #222;
  --kbd-text: #e5e5e5;
}

/* Scroll Template Styles */
.CodeMirror {
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

body {
  font-family: "Arial", sans-serif;
  color: var(--text-color);
  background-color: var(--background-color);
  margin: 0;
  padding: 10px;
  height: 100%;
  padding-bottom: 0;
  box-sizing: border-box;
}

#errorMessage {
  color: var(--error-color);
  flex: 100%;
  padding: 30px 8px 0;
  display: none;
}

.greyText,
.greyText a {
  color: var(--light-grey);
  text-align: center;
  font-size: 0.8rem;
  font-family: monospace;
  margin: auto;
  padding: 0.5rem;
}

.folderActionLink {
  color: var(--light-grey);
}

.fileCommandLink {
  color: var(--light-grey);
  margin-left: 20px;
  cursor: pointer;
}

.drag-over {
  border: 2px dashed var(--primary-color);
  background-color: rgba(var(--primary-color), 0.1);
}

.scrollModal {
  background: var(--modal-color) !important;
}

.scrollModalFit {
  left: calc((100% - 600px) / 2) !important;
  right: calc((100% - 600px) / 2) !important;
  bottom: unset !important;
  width: 600px;
}

.previewIFrame,
.visitIframe {
  height: 900px;
  width: 600px;
  border: 0;
  transform: scale(0.34);
  transform-origin: 0 0;
}

.iframeHolder,
.iframeHolder2 {
  width: 200px;
  height: 125px;
  box-shadow: 2px 2px 2px 2px var(--iframe-shadow);
  border-radius: 8px;
  margin: 10px;
  display: inline-block;
  position: relative;
  overflow: hidden;
}

.visitIframe {
  height: 1800px;
  width: 1200px;
}

.iframeHolder2 {
  width: 400px;
  height: 250px;
}

#folderName {
  outline: none;
}

#fileList {
  margin: 0 10px;
  height: 352px;
  max-height: 100vh;
  width: 200px;
  overflow: auto;
}

#fileList a {
  display: block;
  padding: 0;
  padding-left: 5px;
  margin: 0;
  color: var(--text-color);
}

#fileList a:hover {
  text-decoration: none;
  background-color: var(--hover-bg-color);
}

#fileList a.selectedFile {
  background-color: var(--hover-bg-color);
}

.nonScrollFile {
  color: var(--light-grey) !important;
}

.untracked {
  opacity: 0.5;
}

.createFileButton {
  cursor: pointer;
  padding: 1px 10px;
  margin: 8px;
  border-radius: 5px;
  display: inline-block;
  text-align: center;
}

.createFileButton:hover {
  background-color: var(--hover-bg-color);
}

form {
  background-color: var(--form-background);
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 2px 4px var(--shadow-color);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: top;
  margin: 0 auto;
  max-width: 600px;
  z-index: 3;
}

#importForm {
  margin-top: 20px;
}

#editForm {
  max-width: 1025px;
  margin-top: 20px;
  margin-bottom: 20px;
  padding: 0;
}

.editorHolder {
  border-left: 1px solid var(--border-color);
  padding: 7px;
}

.editorHolder.focusMode {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  font-size: 133%;
  background: var(--focus-mode-bg);
  padding: 0;
  padding-left: calc((100vw - 800px) / 2);
}
.editorHolder.focusMode .CodeMirror-vscrollbar {
  display: none !important;
}

input[type="text"],
textarea {
  flex-grow: 1;
  padding: 10px;
  border: 1px solid var(--border-light);
  border-radius: 4px 0 0 4px;
  font-size: 16px;
  background-color: var(--form-background);
  color: var(--text-color);
}

textarea {
  width: 80ch;
  max-width: 100%;
}

.CodeMirror {
  border: 0;
}

.scrollButton.createButton {
  padding: 10px 20px;
  border-radius: 0 4px 4px 0;
  font-size: 16px;
  margin: 0;
}

.publishButton {
  margin-top: 7px;
  border-radius: 4px;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  body {
    padding: 10px;
  }
  form {
    flex-direction: column;
    align-items: stretch;
  }
  input[type="text"] {
    border-radius: 4px;
    margin-bottom: 10px;
  }
}

#spinner {
  position: fixed;
  top: 0;
  text-align: center;
  left: 0;
  right: 0;
  z-index: 3;
}

#spinner div {
  color: var(--text-color);
  background-color: var(--spinner-bg);
  border: 1px solid var(--border-color);
  padding: 0 10px 2px 10px;
  border-bottom-left-radius: 5px;
  border-bottom-right-radius: 5px;
}

#fileFilter {
  border: 0;
  outline: none;
  background-color: transparent;
  color: var(--text-color);
}

.keyboard-shortcuts {
  padding: 20px;
}

.keyboard-shortcuts h3 {
  margin-bottom: 20px;
  text-align: center;
  font-size: 1.2em;
  color: var(--text-color);
}

.shortcut-category {
  break-inside: avoid;
}

.shortcuts-grid {
  column-count: auto;
  column-fill: auto;
  column-width: min(40ch, 20vw);
  overflow-x: scroll;
  column-gap: 1rem;
  height: calc(100vh - 300px);
}

.shortcut {
  padding: 8px 0;
  cursor: pointer;
  color: var(--text-color);
  display: block;
}

.shortcut kbd {
  background: var(--kbd-bg);
  border-radius: 4px;
  padding: 4px 8px;
  min-width: 24px;
  text-align: center;
  font-family: monospace;
  color: var(--kbd-text);
  transition: background 0.2s;
}

.shortcut:hover kbd {
  background: var(--kbd-hover);
}

.shortcut:active kbd {
  background: var(--kbd-active);
}

.shortcut:active {
  transform: translateY(1px);
}

.newSiteLink a {
  background: var(--primary-color);
  border-radius: 4px;
  padding: 8px 16px;
  margin: 10px;
  min-width: 24px;
  text-align: center;
  display: inline-block;
  text-decoration: none;
  font-family: monospace;
  color: var(--kbd-text);
  transition: background 0.2s;
}

.metric-label {
  color: var(--text-subtle);
  display: inline-block;
  width: 200px;
  padding: 4px 0;
}
.metric-value {
  color: var(--text-default);
  font-weight: bold;
  padding-left: 8px;
}

.binary-file .CodeMirror-lines {
  background-color: #f5f5f5;
  color: #666;
  font-style: italic;
  cursor: not-allowed;
}
.binary-file .CodeMirror-cursor {
  display: none !important;
}

#fileEditor {
  /* Make it smaller and w/o border to avoid flicker */
  width: 70ch;
  border: 0;
}
