:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --text-main: #1f2937;
  --text-sub: #6b7280;
  --bg-body: #f3f4f6;
  --bg-surface: #ffffff;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --font-family: 'Noto Sans SC', system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* Main Container */
.container {
  width: 100%;
  max-width: 1000px;
  background: var(--bg-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-top: 20px;
  border: 1px solid #fff;
}

/* Header */
header {
  padding: 20px 30px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand svg {
  width: 40px;
  height: 40px;
  color: var(--primary);
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  line-height: 1.2;
}

.brand span {
  display: block;
  font-size: 0.75rem;
  color: var(--text-sub);
  font-weight: 400;
  margin-top: 2px;
}

/* Status Badge */
.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  background: #f3f4f6;
  color: var(--text-sub);
  transition: all 0.3s ease;
}

.status-badge.ready {
  background: #dcfce7;
  color: #166534;
}

.status-badge.error {
  background: #fee2e2;
  color: #991b1b;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
}

/* Options Section */
.card-section {
  padding: 24px 30px;
  background: #fafafa;
  border-bottom: 1px solid var(--border);
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.pane-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
}

.pane-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-sub);
}

.btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

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

.btn-secondary {
  background: white;
  border: 1px solid var(--border);
  color: var(--text-sub);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--bg-body);
  border-color: #d1d5db;
}

.options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.options-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

legend {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 8px;
  display: block;
  width: 100%;
}

/* Styled Radio Buttons */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.radio-option {
  position: relative;
}

.radio-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-option input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-option label {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-main);
}

.radio-option label:hover {
  border-color: #cbd5e1;
  background: #f9fafb;
}

.radio-option input:checked+label {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
  box-shadow: 0 0 0 1px var(--primary);
}

/* Disabled State Logic
    We use a class .option-disabled on the wrapper to forcefully style the children
*/
.radio-option.option-disabled {
  pointer-events: none;
  /* Crucial: completely disable clicks */
  opacity: 0.6;
}

.radio-option.option-disabled label {
  background: #f3f4f6;
  border-color: #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
  text-decoration: line-through;
  /* Restored: Clear visual indicator */
  box-shadow: none;
}

/* Editor Area */
.editor-area {
  display: grid;
  grid-template-columns: 1fr 60px 1fr;
  min-height: 450px;
  position: relative;
  background: #fff;
}

.pane {
  display: flex;
  flex-direction: column;
  position: relative;
}

.pane-header {
  padding: 12px 20px;
  border-bottom: 1px solid transparent;
  /* Placeholder alignment */
  background: #fff;
  margin: 0;
}

textarea,
.output-box {
  flex: 1;
  width: 100%;
  border: none;
  resize: none;
  padding: 0 20px 20px 20px;
  font-size: 1.1rem;
  font-family: inherit;
  line-height: 1.6;
  color: var(--text-main);
  background: transparent;
}

textarea:focus {
  outline: none;
}

textarea::placeholder {
  color: #d1d5db;
}

.output-box {
  white-space: pre-wrap;
  overflow-y: auto;
}

/* Divider & Action Button */
.divider {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  position: relative;
}

.action-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(79, 70, 229, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background-color 0.2s;
  z-index: 10;
}

.action-btn:hover {
  background: var(--primary-hover);
  transform: scale(1.1);
}

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

.action-btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.action-btn svg {
  width: 24px;
  height: 24px;
}

/* Copy Button */
.copy-btn {
  font-size: 0.8rem;
  padding: 4px 10px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-sub);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

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

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

/* Footer */
.footer {
  padding: 20px;
  text-align: center;
  font-size: 0.85rem;
  color: #9ca3af;
  border-top: 1px solid var(--border);
  background: #fafafa;
}

.footer p+p {
  margin-top: 12px;
}

.footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

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

.footer .chips {
  justify-content: center;
  margin-bottom: 4px;
}

/* Chips */
.chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 500;
}

button.chip {
  cursor: pointer;
}

button.chip:hover {
  border-color: var(--primary);
}

/* Loader */
.loader {
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top: 2px solid #fff;
  width: 20px;
  height: 20px;
  animation: spin 1s linear infinite;
}

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

  100% {
    transform: rotate(360deg);
  }
}

/* Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: white;
  width: 90%;
  max-width: 600px;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  max-height: 85vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 1.2rem;
  color: var(--text-main);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-sub);
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.config-btn {
  text-align: left;
  background: #fff;
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.config-btn strong {
  display: block;
  color: var(--primary);
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.config-btn span {
  font-size: 0.8rem;
  color: var(--text-sub);
}

/* ========================
   Compare Page Styles
   ======================== */

/* Wider container for compare page */
.container.compare-container {
  max-width: 1400px;
}

/* Input Section */
.input-section {
  padding: 24px 30px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}

.input-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

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

.input-section textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text-main);
  outline: none;
  background: #fff;
  font-family: inherit;
  resize: vertical;
  min-height: 120px;
  transition: all 0.2s;
}

.input-section textarea:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Results Section */
.results-section {
  padding: 24px 30px;
  background: #fff;
}

.results-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

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

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

/* Result Cards */
.result-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  transition: all 0.2s;
}

.result-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.1);
}

.result-card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 8px;
  gap: 8px;
}

.result-card-title {
  flex: 1;
}

.result-card-title strong {
  display: block;
  color: var(--primary);
  font-size: 0.9rem;
  margin-bottom: 2px;
  font-family: 'Courier New', monospace;
}

.result-card-title span {
  font-size: 0.8rem;
  color: var(--text-sub);
}

/* Copy Icon Button */
.copy-icon {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.copy-icon:hover {
  background: #f9fafb;
  border-color: var(--primary);
}

.copy-icon svg {
  width: 14px;
  height: 14px;
  color: var(--text-sub);
}

/* Result Content */
.result-content {
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 60px;
  max-height: 200px;
  overflow-y: auto;
}

.result-content.loading {
  color: var(--text-sub);
  font-style: italic;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-content.error {
  color: #991b1b;
  background: #fee2e2;
}

/* Diff Toggle Checkbox */
.diff-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-sub);
  cursor: pointer;
  user-select: none;
}

.diff-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.diff-toggle:hover {
  color: var(--text-main);
}

/* Diff Highlighting */
.diff-del {
  background-color: #fee2e2;
  color: #991b1b;
  text-decoration: line-through;
  border-radius: 2px;
  padding: 0 2px;
}

.diff-ins {
  background-color: #dcfce7;
  color: #166534;
  border-radius: 2px;
  padding: 0 2px;
}

/* Responsive */
@media (max-width: 768px) {
  body {
    padding: 10px;
    align-items: stretch;
  }

  .container {
    margin-top: 0;
    border-radius: 8px;
  }

  .editor-area {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 60px 1fr;
    min-height: auto;
  }

  .pane {
    min-height: 200px;
  }

  .divider {
    border-left: none;
    border-right: none;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }

  .brand h1 {
    font-size: 1.1rem;
  }

  .brand svg {
    width: 32px;
    height: 32px;
  }

  /* Compare page responsive */
  .results-grid {
    grid-template-columns: 1fr;
  }
}

/* Progress Bar */
.progress-container {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.progress-bar {
  width: 120px;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #7c3aed);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-sub);
  min-width: 35px;
}
