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

html,
body {
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
  position: relative;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #eee;
  background-attachment: fixed;
  min-height: 100vh;
  padding: 1rem;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding: 1rem 0;
  background: #eee;
}

input[type="text"],
input[type="number"],
input[type="color"],
select,
textarea {
  width: 100%;
  max-width: 100%;
  padding: 0.625rem 1rem;
  background: #f9fafb;
  border: 2px solid #e5e7eb;
  border-radius: 0.75rem;
  font-size: 16px;
  transition: all 0.2s;
  color: #1f2937;
  box-sizing: border-box;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #6366f1;
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  z-index: 100;
  border-radius: 0 0 4px 0;
  font-weight: 600;
  max-width: calc(100vw - 2rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skip-link:focus {
  top: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.header {
  text-align: center;
  margin-bottom: 2rem;
  max-width: 100%;
  overflow-wrap: break-word;
}

.header-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #6366f1 0%, #9333ea 100%);
  border-radius: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
}

.header h1 {
  font-size: 3rem;
  background: linear-gradient(135deg, #6366f1 0%, #9333ea 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.header p {
  color: #475569;
  font-size: 1rem;
}

.explainer-section {
  margin-bottom: 1.5rem;
}

.explainer-details {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.explainer-summary {
  padding: 1rem 1.5rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  color: #1f2937;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  user-select: none;
  transition: background 0.2s;
  list-style: none;
}

.explainer-summary::-webkit-details-marker {
  display: none;
}

.explainer-summary::marker {
  display: none;
}

.explainer-summary:hover {
  background: rgba(99, 102, 241, 0.05);
}

.explainer-summary svg {
  flex-shrink: 0;
  color: #6366f1;
}

.explainer-content {
  padding: 0 1.5rem 1.5rem 1.5rem;
  color: #475569;
  font-size: 0.875rem;
  line-height: 1.6;
}

.explainer-content p {
  margin-bottom: 0.75rem;
}

.explainer-content ol,
.explainer-content ul {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.explainer-content li {
  margin-bottom: 0.5rem;
}

.explainer-content code {
  background: #f1f5f9;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-family: 'Courier New', monospace;
  font-size: 0.813rem;
  color: #6366f1;
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 1.5rem;
  width: 100%;
}

@media (max-width: 1024px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
  
  .header h1 {
    font-size: 2rem;
  }
}

.panel {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  border-radius: 1rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 1.5rem;
  width: 100%;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  width: 100%;
}

.panel-header h2 {
  font-size: 1.25rem;
  color: #1f2937;
  word-break: break-word;
}

.accent-bar {
  width: 4px;
  height: 1.5rem;
  background: linear-gradient(180deg, #6366f1 0%, #9333ea 100%);
  border-radius: 1rem;
}

.form-group {
  margin-bottom: 1.5rem;
  width: 100%;
  max-width: 100%;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 0.5rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: 500;
}

input[type="text"],
input[type="number"],
input[type="color"],
select,
textarea {
  width: 100%;
  max-width: 100%;
  padding: 0.625rem 1rem;
  background: #f9fafb;
  border: 2px solid #e5e7eb;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  transition: all 0.2s;
  color: #1f2937;
  box-sizing: border-box;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  margin: 0;
}

input[type="range"] {
  width: 100%;
  cursor: pointer;
  margin: 0.5rem 0;
}

input[type="color"] {
  height: 42px;
  padding: 0.25rem;
  cursor: pointer;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
  background: white;
}

*:focus-visible {
  outline: 3px solid #6366f1;
  outline-offset: 2px;
}

.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: white;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn:focus-visible {
  outline: 3px solid #1f2937;
  outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #9333ea 100%);
}

.btn-primary:hover,
.btn-primary:focus {
  transform: scale(1.05);
  box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.4);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.btn-success:hover,
.btn-success:focus {
  transform: scale(1.05);
  box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
  background: #6b7280;
  color: white;
}

.btn-secondary:hover,
.btn-secondary:focus {
  background: #4b5563;
}

.data-points {
  max-height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.5rem;
  width: 100%;
  max-width: 100%;
}

.data-points::-webkit-scrollbar {
  width: 8px;
}

.data-points::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 10px;
}

.data-points::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 10px;
}

.data-point {
  background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  display: flex;
  gap: 0.5rem;
  transition: all 0.2s;
  width: 100%;
  max-width: 100%;
}

.data-point:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.data-point-inputs {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
  max-width: 100%;
}

.data-point-inputs input {
  padding: 0.5rem 0.75rem;
  background: white;
  font-size: 0.813rem;
  min-width: 0;
}

.btn-delete {
  background: none;
  border: 2px solid transparent;
  color: #ef4444;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.5rem;
  transition: all 0.2s;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.btn-delete:hover,
.btn-delete:focus {
  background: #fef2f2;
  border-color: #ef4444;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
  width: 100%;
}

.chart-title {
  font-size: 1.875rem;
  font-weight: bold;
  color: #1f2937;
  word-break: break-word;
  max-width: 100%;
}

.chart-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.chart-container {
  background: white;
  border-radius: 0.75rem;
  padding: 1rem;
  box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);
  position: relative;
  min-height: 400px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.chart-container canvas {
  max-width: 100% !important;
  height: auto !important;
  display: block;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  padding: 0.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: white;
  border-radius: 1rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  gap: 1rem;
}

.modal-header h3 {
  font-size: 1.5rem;
  color: #1f2937;
  word-break: break-word;
}

.modal-header p {
  font-size: 0.875rem;
  color: #6b7280;
  margin-top: 0.25rem;
}

.btn-close {
  background: none;
  border: 2px solid transparent;
  color: #6b7280;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.5rem;
  transition: all 0.2s;
  line-height: 0;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close:hover,
.btn-close:focus {
  background: #f3f4f6;
  border-color: #6b7280;
  color: #1f2937;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  max-width: 100%;
}

.export-section {
  margin-bottom: 1.5rem;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.export-section:last-child {
  margin-bottom: 0;
}

.export-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.export-header h4 {
  font-size: 1rem;
  color: #1f2937;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  word-break: break-word;
}

.export-code {
  background: #f9fafb;
  border: 2px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 1rem;
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  color: #1f2937;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 240px;
  width: 100%;
  max-width: 100%;
  word-break: break-all;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

.export-description {
  font-size: 0.75rem;
  color: #475569;
  margin-top: 0.5rem;
}

.copy-success {
  color: #10b981 !important;
}

.axis-labels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
  width: 100%;
}

pre {
  max-width: 100%;
  overflow-x: auto;
}

.sr-announcement {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.error-message {
  background: #fef2f2;
  border: 2px solid #ef4444;
  color: #991b1b;
  padding: 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  margin-top: 0.5rem;
  font-weight: 600;
}

.success-message {
  background: #f0fdf4;
  border: 2px solid #10b981;
  color: #065f46;
  padding: 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  margin-top: 0.5rem;
  font-weight: 600;
}

@media (max-width: 840px) {
  .modal-content {
    max-width: calc(100vw - 2rem);
  }
}

@media (max-width: 640px) {
  .header h1 {
    font-size: 1.75rem;
  }
  
  body {
    padding: 0.5rem;
  }

  .panel {
    padding: 1rem;
  }

  .btn {
    font-size: 0.75rem;
    padding: 0.5rem 0.5rem;
    gap: 0.25rem;
  }

  .btn svg {
    flex-shrink: 0;
  }

  .axis-labels {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .chart-container {
    padding: 0.25rem;
    min-height: 300px;
  }

  .modal-content {
    max-width: calc(100vw - 1rem);
    max-height: 95vh;
  }

  .modal-header {
    padding: 1rem;
  }
  
  .modal-header h3 {
    font-size: 1.25rem;
  }

  .modal-body {
    padding: 1rem;
  }

  .export-code {
    font-size: 0.65rem;
    padding: 0.75rem;
    max-height: 200px;
  }

  .export-header h4 {
    font-size: 0.9rem;
  }

  .chart-title {
    font-size: 1.5rem;
    width: 100%;
  }
  
  .chart-actions {
    width: 100%;
    gap: 0.5rem;
  }
  
  .chart-actions .btn {
    flex: 1;
    justify-content: center;
    min-width: 0;
    font-size: 0.75rem;
    padding: 0.5rem 0.5rem;
  }

  .chart-actions .btn svg {
    width: 16px;
    height: 16px;
  }

  /* Prevent zoom on input focus for iOS */
  input[type="text"],
  input[type="number"],
  select,
  textarea {
    font-size: 16px;
  }
}