/* Apple-Style Design System */
:root {
  --apple-blue: #0071e3;
  --apple-blue-hover: #0077ed;
  --apple-gray: #f5f5f7;
  --apple-gray-dark: #1d1d1f;
  --apple-gray-medium: #86868b;
  --apple-gray-light: #fbfbfd;
  --apple-green: #30d158;
  --apple-orange: #ff9500;
  --apple-red: #ff3b30;
  --apple-purple: #bf5af2;

  --border-radius: 18px;
  --border-radius-small: 12px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-large: 0 8px 32px rgba(0, 0, 0, 0.12);
}

/* Reset and Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text',
    'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--apple-gray-light);
  color: var(--apple-gray-dark);
  line-height: 1.47059;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 22px;
}

/* Header */
.header {
  text-align: center;
  padding: 80px 20px 60px;
  background: linear-gradient(180deg, #ffffff 0%, var(--apple-gray-light) 100%);
}

.header-content h1 {
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -0.005em;
  color: var(--apple-gray-dark);
  margin-bottom: 8px;
  line-height: 1.07143;
}

.subtitle {
  font-size: 28px;
  font-weight: 400;
  color: var(--apple-gray-medium);
  line-height: 1.14286;
  letter-spacing: 0.007em;
}

/* Card */
.card {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-radius: var(--border-radius);
  padding: 48px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0, 0, 0, 0.04);
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-large);
}

.card h2 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 28px;
  color: var(--apple-gray-dark);
  letter-spacing: -0.003em;
}

/* Form Styles */
.form-group {
  margin-bottom: 24px;
  flex: 1;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 14px;
  color: var(--apple-gray-dark);
  letter-spacing: -0.016em;
}

.form-group input {
  width: 100%;
  padding: 16px 20px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--border-radius-small);
  font-size: 17px;
  background: #ffffff;
  transition: var(--transition);
  font-family: inherit;
}

.form-group input:focus {
  outline: none;
  border-color: var(--apple-blue);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
}

.form-group input::placeholder {
  color: var(--apple-gray-medium);
}

/* Buttons - Apple Style */
.btn {
  padding: 16px 32px;
  border: none;
  border-radius: 980px;
  font-size: 17px;
  font-weight: 400;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: -0.022em;
  font-family: inherit;
}

.btn-primary {
  background: var(--apple-blue);
  color: white;
  width: 100%;
  margin-top: 12px;
  font-weight: 500;
}

.btn-primary:hover:not(:disabled) {
  background: var(--apple-blue-hover);
  transform: scale(1.01);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--apple-gray-dark);
  color: white;
  font-weight: 500;
}

.btn-secondary:hover {
  background: #424245;
}

.btn-outline {
  background: transparent;
  color: var(--apple-blue);
  border: 2px solid var(--apple-blue);
}

.btn-outline:hover {
  background: var(--apple-blue);
  color: white;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Examples */
.examples {
  margin-top: 32px;
  padding-top: 32px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.examples-label {
  font-size: 14px;
  color: var(--apple-gray-medium);
  margin-bottom: 16px;
  font-weight: 400;
  letter-spacing: -0.016em;
}

.example-btn {
  padding: 10px 20px;
  margin: 6px;
  background: var(--apple-gray);
  border: none;
  border-radius: 980px;
  font-size: 15px;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  color: var(--apple-gray-dark);
}

.example-btn:hover {
  background: #e8e8ed;
  transform: translateY(-1px);
}

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

/* Progress Steps */
.progress-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.progress-step {
  display: flex;
  gap: 20px;
  padding: 28px;
  border-radius: var(--border-radius-small);
  background: var(--apple-gray);
  opacity: 0.4;
  transition: var(--transition);
}

.progress-step.active {
  opacity: 1;
  background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
  box-shadow: 0 2px 12px rgba(0, 113, 227, 0.15);
}

.progress-step.completed {
  opacity: 1;
  background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%);
}

.step-icon {
  font-size: 42px;
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.step-content {
  flex: 1;
  padding-top: 4px;
}

.step-title {
  font-size: 21px;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.021em;
}

.step-desc {
  color: var(--apple-gray-medium);
  font-size: 15px;
  line-height: 1.4;
}

.step-time {
  font-size: 14px;
  color: var(--apple-green);
  font-weight: 500;
  margin-top: 8px;
  letter-spacing: -0.016em;
}

/* Impact Badge */
.impact-badge {
  display: inline-block;
  padding: 12px 28px;
  border-radius: 980px;
  font-weight: 600;
  font-size: 19px;
  color: white;
  margin-bottom: 24px;
  letter-spacing: -0.019em;
}

.impact-low { background: var(--apple-green); }
.impact-medium { background: var(--apple-orange); }
.impact-high { background: #ff9500; }
.impact-critical { background: var(--apple-red); }

/* Issues */
.issue-list {
  margin-top: 24px;
}

.issue-item, .warning-item, .info-item {
  padding: 20px 24px;
  margin: 12px 0;
  border-radius: var(--border-radius-small);
  border-left: 4px solid;
  background: white;
}

.issue-item {
  border-color: var(--apple-red);
  background: linear-gradient(90deg, rgba(255, 59, 48, 0.05) 0%, white 100%);
}

.warning-item {
  border-color: var(--apple-orange);
  background: linear-gradient(90deg, rgba(255, 149, 0, 0.05) 0%, white 100%);
}

.info-item {
  border-color: var(--apple-blue);
  background: linear-gradient(90deg, rgba(0, 113, 227, 0.05) 0%, white 100%);
}

.issue-title {
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 17px;
  letter-spacing: -0.022em;
}

.issue-recommendation {
  color: var(--apple-gray-medium);
  font-size: 15px;
  margin-top: 8px;
  padding-left: 16px;
  border-left: 2px solid rgba(0, 0, 0, 0.08);
  line-height: 1.4;
}

/* Performance Chart */
.performance-bars {
  margin-top: 28px;
}

.performance-bar {
  margin-bottom: 24px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-weight: 500;
  font-size: 15px;
  color: var(--apple-gray-dark);
}

.bar-container {
  background: var(--apple-gray);
  height: 48px;
  border-radius: 980px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--apple-blue) 0%, #5e9fff 100%);
  transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  padding: 0 20px;
  color: white;
  font-weight: 600;
  font-size: 15px;
  border-radius: 980px;
}

/* Comparison Table */
.comparison-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 24px;
}

.comparison-table th,
.comparison-table td {
  padding: 16px 20px;
  text-align: left;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.comparison-table th {
  background: var(--apple-gray);
  font-weight: 600;
  font-size: 14px;
  color: var(--apple-gray-dark);
  letter-spacing: -0.016em;
}

.comparison-table th:first-child {
  border-top-left-radius: var(--border-radius-small);
}

.comparison-table th:last-child {
  border-top-right-radius: var(--border-radius-small);
}

.comparison-table tbody tr {
  transition: var(--transition);
}

.comparison-table tbody tr:hover {
  background: rgba(0, 113, 227, 0.03);
}

.comparison-table tbody tr:last-child td {
  border-bottom: none;
}

.diff-highlight {
  background: rgba(255, 204, 0, 0.2);
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 600;
}

/* Difference Card */
.difference-card {
  background: white;
  padding: 24px;
  border-radius: var(--border-radius-small);
  margin-bottom: 16px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  transition: var(--transition);
}

.difference-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

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

.difference-field {
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.019em;
}

.difference-type {
  background: var(--apple-gray);
  padding: 6px 16px;
  border-radius: 980px;
  font-size: 13px;
  color: var(--apple-gray-medium);
  font-weight: 500;
}

.difference-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.difference-value {
  padding: 16px;
  background: var(--apple-gray);
  border-radius: var(--border-radius-small);
}

.value-label {
  font-size: 13px;
  color: var(--apple-gray-medium);
  margin-bottom: 8px;
  font-weight: 500;
  letter-spacing: -0.013em;
}

.value-content {
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
  font-size: 14px;
  word-break: break-word;
  line-height: 1.5;
  color: var(--apple-gray-dark);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.action-buttons .btn {
  flex: 1;
  min-width: 160px;
}

/* Error */
.error-card {
  border: 2px solid var(--apple-red);
}

#errorMessage {
  background: linear-gradient(135deg, rgba(255, 59, 48, 0.1) 0%, rgba(255, 59, 48, 0.05) 100%);
  padding: 20px 24px;
  border-radius: var(--border-radius-small);
  margin-bottom: 24px;
  color: var(--apple-red);
  font-weight: 500;
  line-height: 1.5;
}

/* Footer */
.footer {
  text-align: center;
  padding: 60px 20px 40px;
  color: var(--apple-gray-medium);
  font-size: 14px;
}

/* Success Message */
.success-message {
  color: var(--apple-green);
  font-weight: 600;
  padding: 20px 24px;
  background: linear-gradient(135deg, rgba(48, 209, 88, 0.1) 0%, rgba(48, 209, 88, 0.05) 100%);
  border-radius: var(--border-radius-small);
  margin-top: 20px;
  font-size: 17px;
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Section Transitions */
.input-section,
.progress-section,
.results-section,
.error-section {
  animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Responsive */
@media (max-width: 1068px) {
  .header-content h1 {
    font-size: 48px;
  }

  .subtitle {
    font-size: 24px;
  }

  .card {
    padding: 36px;
  }

  .card h2 {
    font-size: 28px;
  }
}

@media (max-width: 734px) {
  .header-content h1 {
    font-size: 40px;
  }

  .subtitle {
    font-size: 21px;
  }

  .card {
    padding: 24px;
  }

  .card h2 {
    font-size: 24px;
  }

  .form-row {
    flex-direction: column;
  }

  .difference-values {
    grid-template-columns: 1fr;
  }

  .action-buttons {
    flex-direction: column;
  }

  .action-buttons .btn {
    width: 100%;
  }

  .step-icon {
    width: 56px;
    height: 56px;
    font-size: 32px;
  }

  .container {
    padding: 0 16px;
  }
}

/* Loading State */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--apple-gray-medium);
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--apple-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 16px;
}

/* Smooth Scrolling */
html {
  scroll-behavior: smooth;
}

/* Selection */
::selection {
  background: rgba(0, 113, 227, 0.2);
  color: var(--apple-gray-dark);
}

/* Focus Visible */
*:focus-visible {
  outline: 2px solid var(--apple-blue);
  outline-offset: 2px;
}

button:focus-visible {
  outline-offset: 4px;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: var(--border-radius);
  max-width: 95vw;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 32px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.modal-header h2 {
  font-size: 24px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.024em;
}

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

.modal-copy-btn {
  padding: 10px 20px;
  font-size: 14px;
  border-radius: 980px;
}

.modal-copy-btn.copied {
  background: var(--apple-green);
  color: white;
  border-color: var(--apple-green);
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--apple-gray);
  color: var(--apple-gray-medium);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.modal-close:hover {
  background: #e8e8ed;
  color: var(--apple-gray-dark);
}

.modal-body {
  padding: 32px;
  overflow-y: auto;
  flex: 1;
}

.modal-body pre {
  background: #f8f9fa;
  padding: 24px;
  border-radius: var(--border-radius-small);
  overflow-x: auto;
  overflow-y: auto;
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
  font-size: 13px;
  line-height: 1.8;
  color: var(--apple-gray-dark);
  margin: 0;
  white-space: pre;
  word-wrap: normal;
  border: 1px solid rgba(0, 0, 0, 0.06);
  max-height: 70vh;
}

/* Syntax Highlighting */
.hl-tag {
  color: #0071e3;
  font-weight: 600;
}

.hl-attr {
  color: #bf5af2;
  font-weight: 500;
}

.hl-string {
  color: #30d158;
}

.hl-comment {
  color: var(--apple-gray-medium);
  font-style: italic;
}

@media (max-width: 734px) {
  .modal-content {
    max-height: 90vh;
    max-width: 98vw;
  }

  .modal-header {
    padding: 20px 24px;
    flex-wrap: wrap;
    gap: 12px;
  }

  .modal-actions {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }

  .modal-copy-btn {
    flex: 1;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-body pre {
    font-size: 11px;
    padding: 12px;
    max-height: 75vh;
  }
}
