* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #1f2933;
  min-height: 100vh;
  animation: gradientShift 10s ease infinite;
}

@keyframes gradientShift {
  0%, 100% { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
  50% { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: fadeInUp 0.8s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

header {
  text-align: center;
  margin-bottom: 20px;
}

header h1 {
  margin: 0 0 8px;
  font-size: 3rem;
  font-weight: 700;
  background: linear-gradient(45deg, #fff, #f0f0f0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 4px 8px rgba(0,0,0,0.3);
  animation: titleGlow 2s ease-in-out infinite alternate;
}

@keyframes titleGlow {
  from { filter: drop-shadow(0 0 5px rgba(255,255,255,0.5)); }
  to { filter: drop-shadow(0 0 20px rgba(255,255,255,0.8)); }
}

.subtitle {
  margin: 0;
  color: rgba(255,255,255,0.9);
  font-size: 1.1rem;
  font-weight: 300;
}

.panel {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.1), 0 0 0 1px rgba(255,255,255,0.2);
  display: flex;
  flex-direction: column;
  gap: 20px;
  transform: translateY(20px);
  opacity: 0;
  animation: panelSlideIn 0.6s ease-out forwards;
  transition: all 0.3s ease;
}

.panel:nth-child(2) { animation-delay: 0.1s; }
.panel:nth-child(3) { animation-delay: 0.2s; }
.panel:nth-child(4) { animation-delay: 0.3s; }

@keyframes panelSlideIn {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.panel:hover {
  transform: translateY(-5px);
  box-shadow: 0 25px 50px rgba(0,0,0,0.15), 0 0 0 1px rgba(255,255,255,0.3);
}

.panel h2 {
  margin: 0;
  font-size: 1.5rem;
  color: #4a5568; /* lighter for better contrast */
  position: relative;
}

@media (prefers-color-scheme: dark) {
  .panel h2 {
    color: #e2e8f0; /* much lighter on dark backgrounds */
  }
}

.panel h2::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 0;
  width: 50px;
  height: 3px;
  background: linear-gradient(45deg, #667eea, #764ba2);
  border-radius: 2px;
  animation: underlineGrow 0.8s ease-out 0.5s both;
}

@keyframes underlineGrow {
  from { width: 0; }
  to { width: 50px; }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-content {
  overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.3s ease, padding 0.25s ease;
}

.panel.collapsible .panel-content {
  max-height: 2000px;
  opacity: 1;
  padding-top: 12px;
}

.panel.collapsible.collapsed .panel-content {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
}

.panel.collapsible.collapsed {
  /* Slightly compact the panel when collapsed */
  padding-bottom: 12px;
}

form {
  display: grid;
  gap: 20px;
}

label {
  display: flex;
  flex-direction: column;
  font-weight: 600;
  gap: 8px;
  color: #4a5568;
}

input[type='text'],
input[type='url'] {
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-size: 1rem;
  transition: all 0.3s ease;
  background: rgba(255,255,255,0.8);
}

input[type='text']:focus,
input[type='url']:focus {
  border-color: #667eea;
  outline: none;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
  background: rgba(255,255,255,1);
  transform: translateY(-2px);
}

.options {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.checkbox {
  font-weight: 500;
  gap: 10px;
  align-items: center;
  display: flex;
  color: #4a5568;
  cursor: pointer;
  transition: color 0.2s ease;
}

.checkbox:hover {
  color: #667eea;
}

.checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #667eea;
}

.actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
}

button {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(45deg, #667eea, #764ba2);
  color: #ffffff;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

button:hover::before {
  left: 100%;
}

button[type='button'] {
  background: linear-gradient(45deg, #10b981, #059669);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

button[type='button']:hover:not(:disabled) {
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

.output {
  min-height: 160px;
  background: linear-gradient(135deg, #1a202c, #2d3748);
  color: #e2e8f0;
  padding: 20px;
  border-radius: 12px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  border: 1px solid rgba(255,255,255,0.1);
  position: relative;
}

.output::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, #667eea, transparent);
  animation: scanLine 2s linear infinite;
}

@keyframes scanLine {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.output:empty::after {
  content: 'Ready for input...';
  color: #718096;
  font-style: italic;
}

/* Markdown rendering overrides */
.output.md {
  white-space: normal;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #e2e8f0;
}

.output.md h1,
.output.md h2,
.output.md h3,
.output.md h4,
.output.md h5,
.output.md h6 {
  margin: 0.8em 0 0.4em;
  font-weight: 700;
}

.output.md h1 { font-size: 1.6rem; }
.output.md h2 { font-size: 1.4rem; }
.output.md h3 { font-size: 1.2rem; }

.output.md p { margin: 0.6em 0; }

.output.md a { color: #90cdf4; text-decoration: underline; }

.output.md code {
  background: rgba(255,255,255,0.08);
  padding: 2px 6px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

.output.md pre {
  background: rgba(0,0,0,0.35);
  padding: 12px;
  border-radius: 10px;
  overflow: auto;
}

.output.md pre code { background: transparent; padding: 0; }

.output.md ul, .output.md ol { margin: 0.6em 0 0.6em 1.2em; }
.output.md li { margin: 0.2em 0; }

.output.md blockquote {
  margin: 0.8em 0;
  padding: 8px 12px;
  border-left: 4px solid #718096;
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
}

.status {
  font-size: 0.875rem;
  color: #718096;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(10px);
  animation: statusPulse 2s ease-in-out infinite;
}

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

.status.error {
  color: #f56565;
  background: rgba(245, 101, 101, 0.1);
}

.status.success {
  color: #48bb78;
  background: rgba(72, 187, 120, 0.1);
}

.loading {
  position: relative;
}

.loading::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: 2px solid #e2e8f0;
  border-top: 2px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.footer {
  text-align: center;
  padding: 24px 16px;
  color: rgba(255,255,255,0.8);
  font-size: 0.9rem;
  animation: fadeInUp 1s ease-out 0.8s both;
}

.footer p {
  margin: 8px 0;
}

.footer kbd {
  background: rgba(255,255,255,0.2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-family: inherit;
}

.footer a {
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer a:hover {
  color: #fff;
  text-decoration: underline;
}

/* Fixed height for main log container */
#log-output {
  height: 320px;
}

/* Modal styles */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.modal.show {
  display: flex;
}

.modal-content {
  background: rgba(255, 255, 255, 0.98);
  width: min(1200px, 92vw);
  height: 80vh;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.modal-content .output {
  flex: 1;
  margin: 0;
  border-radius: 0;
}

.modal-close {
  appearance: none;
  border: none;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  color: #4a5568;
}

/* Artifacts list */
.artifacts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.artifact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(0,0,0,0.03);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 10px;
}

.artifact-info {
  display: flex;
  gap: 8px;
  align-items: center;
}

.badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,0.06);
  color: #4a5568;
}

/* Artifact inline renderer */
.artifact-render {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tabbar {
  display: flex;
  gap: 8px;
}

.tab {
  appearance: none;
  border: 1px solid rgba(0,0,0,0.08);
  background: #fff;
  color: #2d3748;
  border-radius: 8px;
  padding: 6px 12px;
  font-weight: 600;
  cursor: pointer;
}

.tab.active {
  background: linear-gradient(45deg, #667eea, #764ba2);
  color: #fff;
  border-color: transparent;
}

@media (max-width: 640px) {
  .container {
    padding: 16px;
  }

  header h1 {
    font-size: 2.5rem;
  }

  .panel {
    padding: 20px;
  }

  .options,
  .actions {
    flex-direction: column;
  }

  button,
  button[type='button'] {
    width: 100%;
    text-align: center;
  }

  .footer {
    padding: 16px;
    font-size: 0.8rem;
  }
}
