body {
  font-family: 'Georgia', serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f5f5;
}

body.dark-mode {
  background-color: #1a1a1a;
  color: #fff;
}

.container {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.dark-mode .container {
  color: #fff;
}

h1 {
  text-align: center;
  color: #2c3e50;
  margin-bottom: 2rem;
  font-size: 2.5rem;
}

.dark-mode h1,
.dark-mode h2 {
  color: #fff;
}

h2 {
  color: #2c3e50;
  font-size: 2rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid #eee;
  padding-bottom: 0.5rem;
}

.input-section {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
}

.input-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.topic-input {
  width: 100%;
  padding: 0.8rem;
  font-size: 1rem;
  border: 2px solid #ddd;
  border-radius: 4px;
  transition: border-color 0.3s ease;
}

.dark-mode .topic-input,
.dark-mode select {
  background-color: #3d3d3d;
  border-color: #4d4d4d;
  color: #fff;
}

.topic-input:focus {
  outline: none;
  border-color: #3498db;
}

.dark-mode .topic-input:focus,
.dark-mode select:focus {
  border-color: #5498db;
}

.select-wrapper {
  position: relative;
}

select {
  width: 100%;
  padding: 0.8rem;
  font-size: 1rem;
  border: 2px solid #ddd;
  border-radius: 4px;
  background-color: white;
  transition: border-color 0.3s ease;
  appearance: none;
  cursor: pointer;
}

.select-wrapper::after {
  content: '▼';
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #666;
}

.dark-mode .select-wrapper::after {
  color: #999;
}

select:focus {
  outline: none;
  border-color: #3498db;
}

button {
  padding: 0.8rem 1.5rem;
  background-color: #3498db;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  transition: background-color 0.3s ease;
  white-space: nowrap;
}

button:hover {
  background-color: #2980b9;
}

.loading {
  display: none;
  text-align: center;
  margin: 2rem 0;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #f3f3f3;
  border-top: 5px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.article-container {
  background-color: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-top: 2rem;
  display: none;
}

.dark-mode .article-container {
  background-color: #2d2d2d;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.article-content {
  margin-top: 1.5rem;
  font-size: 1.1rem;
  line-height: 1.8;
  color: #2c3e50;
  text-align: justify;
}

.dark-mode .article-content {
  color: #e0e0e0;
}

.article-content p {
  margin-bottom: 1.5rem;
}

.article-image-container {
  margin: 1rem 0 2rem 0;
  text-align: center;
}

#articleImage {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.button-group {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  justify-content: center;
}

.button-group button {
  flex: 1;
  max-width: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.button-group button svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.copy-success {
  background-color: #27ae60 !important;
}

.input-group-row {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.topic-input-container {
  flex: 3;
}

.font-size-select-container {
  flex: 1;
}

.input-group-row:first-child {
  margin-bottom: 1rem;
}

.image-input-container {
  flex: 3;
}

.orientation-select-container {
  flex: 1;
}

.content-type-container {
  flex: 2;
}

.author-input-container {
  flex: 1;
}

.keywords-container {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.keywords-main {
  flex: 1;
}

.keywords-label {
  font-weight: bold;
  color: #2c3e50;
  margin-bottom: 0.5rem;
}

.dark-mode .keywords-label {
  color: #fff;
}

.keywords-list {
  color: #666;
  font-size: 0.9rem;
  line-height: 1.6;
  font-style: italic;
}

.dark-mode .keywords-list {
  color: #bbb;
}

.copy-keywords-btn {
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: #3498db;
  transition: color 0.3s ease;
}

.copy-keywords-btn:hover {
  color: #2980b9;
}

.copy-keywords-btn svg {
  width: 20px;
  height: 20px;
}

.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: background-color 0.3s ease;
  z-index: 1000;
}

.theme-toggle:hover {
  background-color: rgba(0,0,0,0.1);
}

.dark-mode .theme-toggle:hover {
  background-color: rgba(255,255,255,0.1);
}

.theme-toggle svg {
  width: 24px;
  height: 24px;
  fill: #333;
  transition: fill 0.3s ease;
}

.dark-mode .theme-toggle svg {
  fill: #fff;
}

.author {
  text-align: left;
  font-style: italic;
  margin-bottom: 2rem;
  color: #666;
}

.dark-mode .author {
  color: #999;
}

.author-controls {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.save-author-btn {
  padding: 0.8rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  background-color: #e74c3c;
}

.save-author-btn.saved {
  background-color: #27ae60;
}

.save-author-btn svg {
  width: 20px;
  height: 20px;
  fill: white;
}

.generate-button-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.iamode-text {
  font-weight: bold;
  color: #3498db;
  font-size: 0.9rem;
  text-transform: uppercase;
}

.dark-mode .iamode-text {
  color: #5498db;
}

/* Media Queries for Responsive Design */
@media screen and (max-width: 768px) {
  .container {
    margin: 1rem auto;
    padding: 0 0.5rem;
  }

  h1 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
  }

  .input-section {
    flex-direction: column;
    gap: 0.5rem;
  }

  .input-group-row {
    flex-direction: column;
    gap: 0.5rem;
  }

  .topic-input-container,
  .font-size-select-container,
  .image-input-container,
  .orientation-select-container,
  .content-type-container,
  .author-input-container {
    width: 100%;
  }

  .generate-button-container {
    width: 100%;
    margin-top: 1rem;
  }

  .generate-button-container button {
    width: 100%;
  }

  .button-group {
    flex-direction: column;
    gap: 0.5rem;
  }

  .button-group button {
    max-width: 100%;
  }

  .keywords-container {
    flex-direction: column;
    align-items: stretch;
  }

  .copy-keywords-btn {
    align-self: flex-end;
    padding: 0.8rem;
  }

  .article-container {
    padding: 1rem;
  }

  .article-content {
    font-size: 16px !important;
  }

  .theme-toggle {
    top: 0.5rem;
    right: 0.5rem;
  }

  .author-controls {
    flex-direction: row;
  }
}

/* Tablet-specific adjustments */
@media screen and (min-width: 769px) and (max-width: 1024px) {
  .container {
    max-width: 90%;
  }

  .input-group-row {
    flex-wrap: wrap;
  }

  .topic-input-container,
  .image-input-container {
    flex: 2;
  }

  .font-size-select-container,
  .orientation-select-container {
    flex: 1;
  }

  .button-group button {
    max-width: none;
    flex: 1;
  }
}

/* Touch device optimizations */
@media (hover: none) {
  .topic-input,
  select,
  button {
    min-height: 44px; /* Minimum touch target size */
  }

  .theme-toggle {
    padding: 0.8rem;
  }

  .copy-keywords-btn {
    padding: 0.8rem;
  }
}

/* High-DPI screen optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .article-image-container img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Prevent text zoom on orientation change */
html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

/* Improve touch targets for interactive elements */
button,
select,
input {
  touch-action: manipulation;
}

/* Safe area insets for modern mobile devices */
@supports (padding: max(0px)) {
  .container {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
}