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

body {
  background-color: black;
  color: white;
  font-family: "Inter", sans-serif;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* Main Page */
#main-page {
  width: 100dvw;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
}

.header {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 1.25rem;
}

/* History Icon */
.history-icon {
  cursor: pointer;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-icon:hover {
  opacity: 0.7;
}

.history-icon img {
  display: block;
}

/* Text Container */
.text-container {
  height: 100%;
  padding: 1.25rem;
  width: 100%;
  text-align: left;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  flex-direction: column;
  gap: 2rem;
}

.previous-text {
  font-size: 1.8rem;
  line-height: 1.6;
  font-weight: 400;
  opacity: 0.6;
  transition: opacity 1s ease;
}

.previous-text.hidden {
  display: none;
}

#generated-text {
  font-size: 1.8rem;
  line-height: 1.6;
  font-weight: 400;
  text-align: left;
  opacity: 1;
  transition: opacity 1s ease;
}

#generated-text.dimmed {
  opacity: 0.6;
}

/* Footer */
.footer {
  padding: 1.25rem;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  opacity: 0.8;
}

.footer-left {
  flex: 1;
  text-align: left;
}

.footer-center {
  flex: 1;
  text-align: center;
}

.footer-right {
  flex: 1;
  text-align: right;
}

/* History Page */
#history-page {
  width: 100dvw;
  height: 100dvh;
  background-color: black;
  overflow-y: auto;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
}

#history-page.hidden {
  display: none;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem;
  flex-shrink: 0;
  background-color: black;
  border-bottom: 1px solid #333333;
  position: sticky;
  top: 0;
  z-index: 100;
}

.history-header h1 {
  font-size: 2rem;
  line-height: 1;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.close-btn:hover {
  opacity: 0.7;
}

.close-btn img {
  display: block;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.5rem;
  padding: 1.25rem;
  overflow-y: auto;
}

.history-item {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 1.5rem;
  transition: all 0.3s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.history-item:hover {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.history-item-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.history-item-text {
  font-size: 0.95rem;
  line-height: 1.6;
  flex: 1;
  opacity: 0.9;
}

.history-item-version {
  font-size: 0.75rem;
  opacity: 0.5;
  text-align: right;
  font-weight: 500;
}

.loading {
  text-align: center;
  opacity: 0.7;
}

/* Typing cursor animation */
.typing-cursor::after {
  content: "|";
  animation: blink 0.7s infinite;
}

@keyframes blink {
  0%,
  50% {
    opacity: 1;
  }
  51%,
  100% {
    opacity: 0;
  }
}

/* Responsive */
@media (max-width: 768px) {
  #generated-text {
    font-size: 1.5rem;
  }

  .previous-text {
    font-size: 1.5rem;
  }

  .text-container {
    gap: 1.5rem;
  }

  .header {
    padding: 1rem;
  }

  .text-container {
    padding: 1rem;
  }

  .footer {
    font-size: 0.75rem;
    padding: 1rem;
    justify-content: start;
    gap: 0.5rem;
    flex-wrap: wrap;
  }
  .footer-left {
    flex: none;
    text-align: left;
  }
  .footer-center {
    flex: none;
    text-align: left;
  }
  .footer-right {
    flex: none;
    text-align: left;
  }

  .history-icon img {
    width: 24px;
    height: 24px;
  }

  .close-btn img {
    width: 24px;
    height: 24px;
  }

  .history-header {
    padding: 1rem;
  }

  .history-list {
    grid-template-columns: 1fr;
    padding: 0 1rem 1rem 1rem;
  }

  .history-item {
    padding: 1rem;
  }
}
