:root {
  --primary-color: #2c3e50;
  --accent-color: #8b0000;
  --background-color: #f4f1ea;
  --text-color: #222;
  --paper-texture: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23noise)' opacity='0.08'/%3E%3C/svg%3E");
}

[data-theme="classic"] {
  --primary-color: #2c3e50;
  --accent-color: #8b0000;
  --background-color: #f4f1ea;
  --text-color: #222;
}

[data-theme="modern"] {
  --primary-color: #2c3e50;
  --accent-color: #e74c3c;
  --background-color: #f5f6fa;
  --text-color: #2c3e50;
}

[data-theme="dark"] {
  --primary-color: #d4d4d4;
  --accent-color: #bf4040;
  --background-color: #1a1a1a;
  --text-color: #ffffff;
}

body {
  font-family: 'Playfair Display', 'Georgia', serif;
  margin: 0;
  padding: 0;
  background-color: var(--background-color);
  color: var(--text-color);
  background-image: var(--paper-texture);
}

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

header {
  text-align: center;
  margin-bottom: 3rem;
  border-bottom: 3px double var(--text-color);
  padding-bottom: 1rem;
}

.masthead {
  font-family: 'UnifrakturMaguntia', cursive;
  font-size: 4rem;
  color: var(--accent-color);
  margin: 0;
  text-shadow: 2px 2px 0px rgba(0,0,0,0.1);
}

.date-banner {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--text-color);
  border-bottom: 1px solid var(--text-color);
  padding: 0.5rem 0;
  margin: 1rem 0;
  font-style: italic;
  font-size: 0.9rem;
}

.tagline {
  font-style: italic;
  color: var(--text-color);
  opacity: 0.8;
  font-size: 1.2rem;
  margin-top: 0.5rem;
}

.customization-panel {
  background: rgba(255,255,255,0.1);
  padding: 1.5rem;
  border-radius: 8px;
  margin-bottom: 2rem;
  border: 1px solid var(--text-color);
  transition: all 0.3s ease;
}

.customize-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.control-group {
  padding: 0.5rem;
  border: 1px dashed var(--text-color);
}

.control-group h4 {
  margin: 0 0 0.5rem 0;
  font-style: italic;
}

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

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}

select {
  background-color: var(--background-color);
  padding: 0.8rem;
  border-radius: 4px;
  width: 100%;
  cursor: pointer;
}

select:focus {
  outline: 2px solid var(--accent-color);
}

select:disabled {
  cursor: not-allowed;
  background-color: rgba(0,0,0,0.05);
}

.range-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.range-value {
  min-width: 3rem;
  text-align: right;
}

input[type="range"] {
  margin: 0;
  width: 100%;
}

.article-style-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.style-btn {
  flex: 1 1 calc(25% - 0.5rem);
  min-width: 120px;
  text-align: center;
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--text-color);
  background: transparent;
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.3s ease;
}

.style-btn.active {
  background: var(--accent-color);
  color: var(--background-color);
}

.theme-selector {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.theme-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--text-color);
  background: transparent;
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.3s ease;
}

.theme-btn.active {
  background: var(--accent-color);
  color: var(--background-color);
}

.input-section {
  background: rgba(255,255,255,0.5);
  padding: 2rem;
  border-radius: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 2rem;
  border: 1px solid var(--text-color);
  transition: box-shadow 0.3s ease;
}

.input-section:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

input {
  width: 100%;
  padding: 0.8rem;
  margin: 1rem 0;
  border: 1px solid var(--text-color);
  background: transparent;
  font-family: 'Playfair Display', serif;
  color: var(--text-color);
}

.prompt-controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.prompt-controls input {
  margin: 0;
  flex-grow: 1;
}

.secondary-btn {
  background: transparent;
  color: var(--accent-color);
  border: 2px solid var(--accent-color);
  padding: 0.5rem 1rem;
}

.secondary-btn:hover {
  background: var(--accent-color);
  color: var(--background-color);
}

button {
  background: var(--accent-color);
  color: white;
  border: none;
  padding: 1rem 2rem;
  cursor: pointer;
  font-family: 'Playfair Display', serif;
  transition: background 0.3s ease;
}

button:hover {
  filter: brightness(1.2);
}

.grape-btn {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.grape-btn:hover {
  transform: scale(1.1);
}

.grape-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.grape-btn:active {
  transform: scale(0.95);
}

.output-section {
  background: rgba(255,255,255,0.5);
  padding: 2rem;
  border: 1px solid var(--text-color);
  position: relative;
  width: 100%;
  display: block;
}

article {
  line-height: 1.8;
  width: 100%;
}

#content {
  font-size: 1.1rem;
  text-align: justify;
  margin: 0;
  padding: 0;
  column-count: 2;
  column-gap: 2rem;
}

.meta {
  font-style: italic;
  opacity: 0.8;
  margin: 1rem 0;
  font-size: 0.9rem;
  width: 100%;
}

footer {
  text-align: center;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 3px double var(--text-color);
  font-style: italic;
  opacity: 0.8;
}

.hidden {
  display: none !important;
}

#loading {
  text-align: center;
  padding: 2rem;
  animation: pulse 2s infinite;
  width: 100%;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#loading p {
  font-style: italic;
  color: var(--accent-color);
  margin-top: 1rem;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

.newspaper .paper {
  fill: var(--background-color);
  stroke: var(--text-color);
  stroke-width: 2;
}

.newspaper .text-line {
  stroke: var(--text-color);
  stroke-width: 2;
  stroke-linecap: round;
  animation: typing 1.5s infinite;
}

.newspaper .text-line:nth-child(2) {
  animation-delay: 0.2s;
}

.newspaper .text-line:nth-child(3) {
  animation-delay: 0.4s;
}

.newspaper .text-line:nth-child(4) {
  animation-delay: 0.6s;
}

@keyframes typing {
  0% { transform: scaleX(0.3); opacity: 0.3; }
  50% { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(0.3); opacity: 0.3; }
}

.temperature-display {
  font-weight: bold;
  color: var(--accent-color);
  min-width: 3.5rem;
}

.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 100%;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 30px;
  background-color: #ccc;
  border-radius: 34px;
  transition: .4s;
  margin-right: 10px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  border-radius: 50%;
  transition: .4s;
}

input:checked + .toggle-slider {
  background-color: var(--accent-color);
}

input:checked + .toggle-slider:before {
  transform: translateX(30px);
}

.toggle-label {
  font-size: 0.9rem;
}

@media (max-width: 768px) {
  .output-section {
    padding: 1.5rem;
  }
  #content {
    font-size: 1rem;
    column-count: 1;
  }
  h2 {
    font-size: 1.75rem;
  }
}

h2 {
  font-family: 'Playfair Display', serif;
  font-weight: 900;
  font-size: 2rem;
  margin-bottom: 1rem;
  line-height: 1.2;
  transition: color 0.3s ease;
}

article:hover h2 {
  color: var(--accent-color);
}

.article-actions {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--text-color);
  text-align: center;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.save-btn, .copy-btn, .share-btn, .print-btn {
  background: var(--primary-color);
  color: var(--background-color);
  border: 2px solid var(--primary-color);
  padding: 0.8rem 1.5rem;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.save-btn::before, .copy-btn::before, .share-btn::before, .print-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.save-btn:active::before, .copy-btn:active::before, .share-btn:active::before, .print-btn:active::before {
  width: 300px;
  height: 300px;
}

.save-btn:hover, .copy-btn:hover, .share-btn:hover, .print-btn:hover {
  background: transparent;
  color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.copy-btn {
  background: #27ae60;
  border-color: #27ae60;
}

.copy-btn:hover {
  color: #27ae60;
}

.share-btn {
  background: #3498db;
  border-color: #3498db;
}

.share-btn:hover {
  color: #3498db;
}

.print-btn {
  background: #95a5a6;
  border-color: #95a5a6;
}

.print-btn:hover {
  color: #95a5a6;
}

.saved-articles-section {
  background: rgba(255,255,255,0.3);
  padding: 1.5rem;
  border-radius: 8px;
  margin-top: 2rem;
  border: 1px solid var(--text-color);
}

.saved-articles-section h3 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 1rem 0;
  font-style: italic;
}

.toggle-saved-btn {
  background: transparent;
  color: var(--accent-color);
  border: 1px solid var(--accent-color);
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
}

.saved-articles-list {
  max-height: 400px;
  overflow-y: auto;
}

.saved-article-item {
  background: rgba(255,255,255,0.5);
  border: 1px solid var(--text-color);
  padding: 1rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.saved-article-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 3px;
  background: var(--accent-color);
  transform: scaleY(0);
  transition: transform 0.3s ease;
}

.saved-article-item:hover::before {
  transform: scaleY(1);
}

.saved-article-item:hover {
  background: rgba(255,255,255,0.8);
  transform: translateX(5px);
  box-shadow: -2px 2px 8px rgba(0,0,0,0.1);
}

.saved-article-headline {
  font-weight: bold;
  color: var(--accent-color);
  margin-bottom: 0.5rem;
}

.saved-article-meta {
  font-size: 0.8rem;
  opacity: 0.7;
  font-style: italic;
}

.saved-article-actions {
  margin-top: 0.5rem;
}

.delete-saved-btn {
  background: var(--accent-color);
  color: var(--background-color);
  border: none;
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  margin-left: 0.5rem;
}

.no-saved {
  text-align: center;
  opacity: 0.7;
  font-style: italic;
}

.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--accent-color);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 1000;
  animation: slideIn 0.3s ease, slideOut 0.3s ease 2.7s;
  opacity: 0;
  pointer-events: none;
}

.notification.show {
  opacity: 1;
  pointer-events: auto;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

@media print {
  .customization-panel,
  .input-section,
  .article-actions,
  .saved-articles-section,
  footer,
  button {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
  }
  
  .output-section {
    border: none;
    box-shadow: none;
  }
  
  #content {
    column-count: 2;
    column-gap: 2rem;
  }
  
  .masthead {
    color: black;
  }
}