:root {
  --bg: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #f1f3f4;
  --border: #e1e4e8;
  --text: #24292f;
  --text-secondary: #57606a;
  --text-muted: #8b949e;
  --accent: #0969da;
  --accent-light: #ddf4ff;
  --error: #cf222e;
  --error-bg: #ffebe9;
  --success: #1a7f37;
  --font-mono: "SF Mono", "Consolas", "Liberation Mono", monospace;
  --font-sans:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --transition: 0.15s ease;
}

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

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

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.library-selector {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}

.library-option {
  cursor: pointer;
}

.library-option input {
  display: none;
}

.library-option span {
  display: block;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
  white-space: nowrap;
}

.library-option:hover span {
  color: var(--text);
  background: var(--bg-tertiary);
}

.library-option input:checked + span {
  background: var(--accent);
  color: white;
}

/* Main */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Panels */
.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  flex: 1;
  min-height: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

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

.panel-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.panel-actions {
  display: flex;
  gap: 0.25rem;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--bg-tertiary);
  color: var(--text);
}

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

/* Textarea */
textarea {
  flex: 1;
  width: 100%;
  padding: 0.75rem;
  border: none;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  resize: none;
}

textarea:focus {
  outline: none;
}

textarea::placeholder {
  color: var(--text-muted);
}

/* Code Output */
.code-container {
  flex: 1;
  overflow: auto;
  background: var(--bg);
}

.code-container pre {
  margin: 0;
  padding: 0.75rem;
  min-height: 100%;
}

.code-container code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
}

/* Options Bar */
.options-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-wrap: wrap;
}

.option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: color var(--transition);
  white-space: nowrap;
}

.option:hover {
  color: var(--text);
}

.option input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

.option.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Error Message */
.error-message {
  padding: 0.6rem 0.75rem;
  background: var(--error-bg);
  border: 1px solid var(--error);
  border-radius: var(--radius);
  color: var(--error);
  font-size: 0.85rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 0.6rem 1rem;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius);
  font-size: 0.85rem;
  transition: transform 0.2s ease;
  z-index: 1000;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Footer */
footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

.separator {
  opacity: 0.3;
}

.hint {
  opacity: 0.7;
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 900px) {
  .panels {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .container {
    padding: 0.75rem;
  }

  header {
    flex-direction: column;
    align-items: stretch;
  }

  header h1 {
    text-align: center;
  }

  .library-selector {
    justify-content: center;
  }

  .options-bar {
    justify-content: center;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Placeholder for empty output */
.code-container code:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
}

/* Language toggle */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-lang {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-lang:hover {
  background: var(--bg-tertiary);
  color: var(--text);
}
