* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #000000;
  color: #ffffff;
  font-family: 'JetBrains Mono', monospace;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Header */
#header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  padding: 1rem 1.5rem;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  opacity: 0.85;
  font-weight: 400;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  gap: 0.75rem;
  position: relative;
}

/* Header Buttons */
.header-button {
  background: transparent;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.5);
  padding: 0.5rem 1.25rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.625rem;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: all 0.2s ease;
  font-weight: 500;
  white-space: nowrap;
}

.header-button:hover {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
}

.header-button:active {
  transform: scale(0.96);
}

#open-button {
  justify-self: start;
  grid-column: 1;
  grid-row: 1;
}

#save-button {
  justify-self: end;
  grid-column: 3;
  grid-row: 1;
}

#file-title {
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  grid-column: 2;
  grid-row: 1;
  font-size: 0.75rem;
  opacity: 0.9;
}

#save-indicator {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  font-size: 0.5rem;
  opacity: 0;
  transition: opacity 0.3s ease;
  letter-spacing: 0.15em;
  pointer-events: none;
}

#save-indicator.show {
  opacity: 0.7;
  animation: saveFlash 1.5s ease-out;
}

@keyframes saveFlash {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* Mobile Optimization */
@media (max-width: 768px) {
  #header {
    padding: 0.875rem 1rem;
    gap: 0.5rem;
  }

  .header-button {
    padding: 0.4rem 0.875rem;
    font-size: 0.5625rem;
  }

  #file-title {
    font-size: 0.625rem;
  }

  #save-indicator {
    top: 0.875rem;
    right: 1rem;
    font-size: 0.4375rem;
  }
}

@media (max-width: 480px) {
  #header {
    padding: 0.75rem 0.75rem;
  }

  .header-button {
    padding: 0.35rem 0.625rem;
    font-size: 0.5rem;
  }

  #file-title {
    font-size: 0.5625rem;
  }
}

/* Editor Container */
#editor-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  justify-content: center;
  padding: 0 2rem 4rem 2rem;
  position: relative;
}

/* Mobile padding adjustments */
@media (max-width: 768px) {
  #editor-container {
    padding: 0 1.5rem 3rem 1.5rem;
  }
}

@media (max-width: 480px) {
  #editor-container {
    padding: 0 1rem 2.5rem 1rem;
  }
}

/* Custom Scrollbar - Hidden by default, shows on hover */
#editor-container::-webkit-scrollbar {
  width: 10px;
}

#editor-container::-webkit-scrollbar-track {
  background: transparent;
}

#editor-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0);
  transition: background 0.3s ease;
}

#editor-container:hover::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.4);
}

#editor-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.6);
}

/* Mobile scrollbar - always slightly visible */
@media (max-width: 768px) {
  #editor-container::-webkit-scrollbar {
    width: 6px;
  }

  #editor-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
  }

  #editor-container:hover::-webkit-scrollbar-thumb,
  #editor-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
  }
}

/* Editor Wrapper - Centers content */
#editor-wrapper {
  width: 100%;
  max-width: 65ch;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Editor */
/* Editor */
#editor {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  line-height: 1.8;
  padding: 0;
  text-align: left;
  min-height: 100vh;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Placeholder for empty editor */
#editor:empty:before {
  content: attr(data-placeholder);
  color: rgba(255, 255, 255, 0.3);
  pointer-events: none;
}

/* Formatting styles */
#editor strong,
#editor b {
  font-weight: 700;
  color: #ffffff;
}

#editor em,
#editor i {
  font-style: italic;
  color: #ffffff;
}

#editor u {
  text-decoration: underline;
  color: #ffffff;
}

/* Preserve formatting on paste */
#editor * {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

#editor::selection {
  background: #ffffff;
  color: #000000;
}

#editor:focus {
  outline: none;
}

/* Mobile font size adjustments */
@media (max-width: 768px) {
  #editor {
    font-size: 0.9375rem;
    line-height: 1.7;
  }
}

@media (max-width: 480px) {
  #editor {
    font-size: 0.875rem;
    line-height: 1.65;
  }
}

/* Instructions */
#instructions {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.625rem;
  opacity: 0.25;
  letter-spacing: 0.1em;
  pointer-events: none;
  text-align: center;
  transition: opacity 0.3s ease;
}

body:hover #instructions {
  opacity: 0.35;
}

/* Mobile instructions adjustments */
@media (max-width: 768px) {
  #instructions {
    bottom: 1.5rem;
    font-size: 0.5625rem;
  }
}

@media (max-width: 480px) {
  #instructions {
    bottom: 1rem;
    font-size: 0.5rem;
    letter-spacing: 0.05em;
  }
}

/* Fade in animation */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

body {
  animation: fadeIn 0.5s ease-out;
}