*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-color: #0a0a0f;
  --text-primary: #f5f5f7;
  --text-secondary: #8b8b96;
  --accent: #c4f052;
  --accent-dim: #9bc23d;
  --surface: rgba(255, 255, 255, 0.03);
  --surface-hover: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(196, 240, 82, 0.4);
  --error: #ff6b6b;
  --success: #4ade80;
  --warning: #fbbf24;
}

html,
body {
  height: 100%;
}

body {
  font-family: "Plus Jakarta Sans", sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Color Vision Simulation Filters */
.vision-protanopia {
  filter: url('#protanopia-filter');
}

.vision-deuteranopia {
  filter: url('#deuteranopia-filter');
}

.vision-tritanopia {
  filter: url('#tritanopia-filter');
}

.vision-achromatopsia {
  filter: grayscale(100%);
}

/* Background Pattern */
.bg-pattern {
  position: fixed;
  inset: 0;
  background-image: radial-gradient(
      circle at 20% 80%,
      rgba(196, 240, 82, 0.03) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 20%,
      rgba(100, 120, 200, 0.03) 0%,
      transparent 50%
    ),
    linear-gradient(rgba(255, 255, 255, 0.01) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.01) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 60px 60px, 60px 60px;
  pointer-events: none;
  z-index: -1;
}

/* Layout */
.container {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  padding: 2rem 3rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.header-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--accent);
  color: var(--text-primary);
}

.header-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.header-btn svg {
  opacity: 0.7;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-mark {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dim) 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-mark svg {
  width: 18px;
  height: 18px;
}

.logo-text {
  font-family: "Instrument Serif", serif;
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: -0.02em;
}

.badge {
  font-family: "DM Mono", monospace;
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Main Content */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 420px 1fr;
  min-height: 0;
}

@media (max-width: 1024px) {
  main {
    grid-template-columns: 1fr;
  }
}

/* Sidebar */
.sidebar {
  padding: 2rem;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-header .section-title {
  margin-bottom: 0;
}

.section-title {
  font-family: "DM Mono", monospace;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.section-header .section-title::after {
  display: none;
}

/* Swap Button */
.swap-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: "DM Mono", monospace;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.swap-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--accent);
  color: var(--accent);
}

.swap-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Input Group */
.input-group {
  position: relative;
}

.input-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.color-input {
  width: 100%;
  padding: 1rem 1.25rem;
  padding-left: 3.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: "DM Mono", monospace;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  outline: none;
}

.color-input:focus {
  border-color: var(--border-focus);
  background: var(--surface-hover);
  box-shadow: 0 0 0 3px rgba(196, 240, 82, 0.1);
}

.color-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

.color-preview-input {
  position: absolute;
  left: 1rem;
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  padding: 0;
  overflow: hidden;
}

.color-preview-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-preview-input::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.input-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  font-family: "DM Mono", monospace;
}

.input-error {
  color: var(--error);
  font-size: 0.8rem;
  margin-top: 0.5rem;
  display: none;
  align-items: center;
  gap: 0.35rem;
}

.input-error.visible {
  display: flex;
}

/* Contrast Warning */
.contrast-warning {
  display: none;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.3);
  border-radius: 10px;
  margin-top: 0.75rem;
}

.contrast-warning.visible {
  display: flex;
}

.contrast-warning.pass {
  background: rgba(74, 222, 128, 0.1);
  border-color: rgba(74, 222, 128, 0.3);
}

.contrast-warning.limited {
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.3);
}

.warning-icon {
  flex-shrink: 0;
  color: var(--error);
}

.contrast-warning.pass .warning-icon {
  color: var(--success);
}

.contrast-warning.limited .warning-icon {
  color: var(--warning);
}

.warning-content {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.warning-title {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--error);
}

.contrast-warning.pass .warning-title {
  color: var(--success);
}

.contrast-warning.limited .warning-title {
  color: var(--warning);
}

.warning-text {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: "DM Mono", monospace;
}

/* Apply Text Button */
.apply-text-btn {
  width: 100%;
  padding: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.apply-text-btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.apply-text-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Apply Button */
.apply-btn {
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dim) 100%);
  border: none;
  border-radius: 12px;
  color: #0a0a0f;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.apply-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(196, 240, 82, 0.25);
}

.apply-btn:active {
  transform: translateY(0);
}

/* Color Suggestions */
.suggestions-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
}

.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.suggestion-card {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.suggestion-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.suggestion-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.suggestion-card.selected {
  border-color: var(--accent);
  background: rgba(196, 240, 82, 0.05);
}

.suggestion-card.selected::before {
  content: "✓";
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: #0a0a0f;
  font-weight: bold;
}

.suggestion-swatch {
  width: 100%;
  height: 40px;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.suggestion-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.suggestion-code {
  font-family: "DM Mono", monospace;
  font-size: 0.75rem;
  color: var(--text-primary);
}

.suggestion-ratio {
  font-size: 0.7rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.ratio-badge {
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-family: "DM Mono", monospace;
  font-size: 0.65rem;
  font-weight: 500;
}

.ratio-badge.aaa {
  background: rgba(74, 222, 128, 0.15);
  color: var(--success);
}

.ratio-badge.aa {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warning);
}

.ratio-badge.fail {
  background: rgba(255, 107, 107, 0.15);
  color: var(--error);
}

/* Vision Simulation Section */
.vision-section {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.vision-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.vision-btn {
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: "DM Mono", monospace;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.vision-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.vision-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0a0f;
}

/* Preview Panel */
.preview-panel {
  padding: 3rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  overflow-y: auto;
  transition: background-color 0.4s ease;
}

.preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
}

.contrast-display {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.contrast-value {
  font-family: "Instrument Serif", serif;
  font-size: 4rem;
  font-weight: 400;
  line-height: 1;
  transition: color 0.3s ease;
}

.contrast-label {
  font-family: "DM Mono", monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.7;
  transition: color 0.3s ease;
}

.wcag-badges {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-end;
}

.wcag-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-family: "DM Mono", monospace;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.3s ease;
}

.wcag-badge.pass {
  background: rgba(74, 222, 128, 0.15);
  color: var(--success);
}

.wcag-badge.fail {
  background: rgba(255, 107, 107, 0.15);
  color: var(--error);
}

.wcag-badge svg {
  width: 14px;
  height: 14px;
}

/* Text Preview Area */
.text-preview-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.text-input-container {
  position: relative;
}

.text-input {
  width: 100%;
  padding: 1.25rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  color: inherit;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 1rem;
  resize: vertical;
  min-height: 100px;
  outline: none;
  transition: all 0.2s ease;
}

.text-input:focus {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.3);
}

.text-input::placeholder {
  color: inherit;
  opacity: 0.5;
}

/* Sample Text Blocks */
.sample-texts {
  display: grid;
  gap: 1.5rem;
}

.sample-block {
  padding: 2rem;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: color 0.3s ease;
}

.sample-block h3 {
  font-family: "Instrument Serif", serif;
  font-size: 2rem;
  font-weight: 400;
  margin-bottom: 0.75rem;
  line-height: 1.2;
}

.sample-block p {
  font-size: 1rem;
  opacity: 0.85;
  line-height: 1.7;
}

.sample-block.small-text p {
  font-size: 0.875rem;
}

.sample-block .label {
  font-family: "DM Mono", monospace;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.5;
  margin-bottom: 1rem;
  display: block;
}

/* Color Info Strip */
.color-info-strip {
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  flex-wrap: wrap;
}

.color-info-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.color-info-label {
  font-family: "DM Mono", monospace;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.5;
}

.color-info-value {
  font-family: "DM Mono", monospace;
  font-size: 0.85rem;
}

.color-info-value.copyable {
  cursor: pointer;
  transition: opacity 0.2s ease;
  position: relative;
}

.color-info-value.copyable:hover {
  opacity: 0.7;
}

.color-info-value.copyable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.color-info-value.copied {
  color: var(--success);
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 0.75rem 1.25rem;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: "Plus Jakarta Sans", sans-serif;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
  pointer-events: none;
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  border-color: var(--success);
  background: rgba(74, 222, 128, 0.1);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-color);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.modal-overlay.visible .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-family: "Instrument Serif", serif;
  font-size: 1.5rem;
  font-weight: 400;
}

.modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
}

.export-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.export-tab {
  padding: 0.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: "DM Mono", monospace;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.export-tab:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.export-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0a0f;
}

.export-code-container {
  position: relative;
}

.export-code {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  font-family: "DM Mono", monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-primary);
  overflow-x: auto;
  white-space: pre;
  max-height: 300px;
  overflow-y: auto;
}

.copy-code-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: "DM Mono", monospace;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.copy-code-btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  color: var(--text-primary);
}

/* Responsive */
@media (max-width: 1024px) {
  header {
    padding: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
  }

  .header-actions {
    flex-wrap: wrap;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .preview-panel {
    padding: 2rem 1.5rem;
  }

  .contrast-value {
    font-size: 3rem;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Initial state */
.preview-panel.no-color {
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state {
  text-align: center;
  max-width: 400px;
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  background: var(--surface);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  border: 1px solid var(--border);
}

.empty-state-icon svg {
  width: 36px;
  height: 36px;
  opacity: 0.4;
}

.empty-state h2 {
  font-family: "Instrument Serif", serif;
  font-size: 1.75rem;
  font-weight: 400;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.preview-content {
  display: none;
}

.preview-panel.active .empty-state {
  display: none;
}

.preview-panel.active .preview-content {
  display: contents;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.preview-panel.active .preview-content > * {
  animation: fadeIn 0.4s ease forwards;
}

.preview-panel.active .preview-content > *:nth-child(1) {
  animation-delay: 0s;
}
.preview-panel.active .preview-content > *:nth-child(2) {
  animation-delay: 0.1s;
}
.preview-panel.active .preview-content > *:nth-child(3) {
  animation-delay: 0.2s;
}
.preview-panel.active .preview-content > *:nth-child(4) {
  animation-delay: 0.3s;
}

footer {
  text-align: center;
  margin: 1rem auto;
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: #666;
}

footer a {
  color: #4ecdc4;
  text-decoration: none;
}

/* Focus visible for better keyboard navigation */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}