:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --border: #dee2e6;
  --text: #212529;
  --text-muted: #6c757d;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --radius: 8px;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  gap: 0.5rem;
}

.card-header h2 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

textarea {
  width: 100%;
  flex: 1;
  min-height: 400px;
  padding: 1rem;
  border: none;
  outline: none;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
  border-radius: 0 0 var(--radius) var(--radius);
  word-break: break-word;
  overflow-wrap: break-word;
}

#output {
  width: 100%;
  flex: 1;
  min-height: 400px;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
  overflow-x: hidden;
  overflow-y: auto;
  color: var(--text);
}

#output pre, #output code {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
}

#output img, #output table {
  max-width: 100%;
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

select {
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.8rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.btn {
  padding: 0.375rem 0.75rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: background 0.15s;
}

.btn:hover {
  background: var(--bg);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.content-grid {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 2rem;
  margin-top: 3rem;
}

.content-main {
  min-width: 0;
}

.ad-sidebar {
  position: sticky;
  top: 2rem;
  align-self: start;
}

.ad-container {
  min-height: 250px;
}

.ad-horizontal {
  max-width: 800px;
  margin: 2rem auto 0;
}

.content-section {
  max-width: 800px;
  margin: 0 auto 2rem;
}

.content-section h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.content-section h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.375rem;
}

.content-section p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.content-section ol {
  color: var(--text-muted);
  font-size: 0.95rem;
  padding-left: 1.5rem;
  margin-bottom: 0.75rem;
}

.content-section ol li {
  margin-bottom: 0.375rem;
}

.content-section code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.125rem 0.375rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.site-footer {
  margin-top: 3rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
}

.site-footer p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.site-footer a {
  color: var(--text-muted);
  text-decoration: underline;
}

.site-footer a:hover {
  color: var(--text);
}

@media (max-width: 768px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .ad-sidebar {
    position: static;
  }

  textarea, #output {
    min-height: 250px;
  }

  .container {
    padding: 1rem 1rem;
  }
}
