@media screen and (max-width: 768px) {
  body {
    height: auto;
    overflow-y: auto;
    flex-direction: column;
  }

  /* Header Optimization */
  .header {
    flex-direction: column;
    padding: 10px 15px;
    gap: 10px;
  }

  .header-left {
    width: 100%;
    justify-content: space-between;
  }

  .header h1 {
    font-size: 18px;
  }

  .header-about-link {
    font-size: 12px;
    padding: 4px 8px;
  }

  .language-selector {
    width: 100%;
    justify-content: space-between;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 10px;
  }
  
  .language-selector label {
    display: none;
  }
  
  .language-select-container {
    width: 100%;
  }

  .language-selector select {
    width: 100%;
    padding: 6px 10px;
  }

  /* Main Content Layout */
  .container {
    flex-direction: column;
    padding: 10px;
    gap: 15px;
    height: auto;
  }

  .panel {
    width: 100% !important;
    height: 60vh !important; /* Give each panel reasonable height on mobile */
    min-height: 400px;
    margin-bottom: 20px;
  }

  .panel.left-panel {
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
  }

  /* Toolbar Optimization */
  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    height: auto;
    padding: 10px;
  }

  .panel-controls {
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 5px;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling for iOS */
  }

  .control-row {
    display: flex;
    gap: 8px;
  }

  .btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  /* Editor Area */
  .input-container, .output-container {
    height: calc(100% - 80px); /* Adjust based on new header height */
  }

  .line-numbers {
    width: 30px;
    font-size: 11px;
    padding: 10px 2px;
  }

  .input-area, .output-area {
    padding: 10px;
    font-size: 13px; /* Prevent iOS zoom on focus */
    margin-left: 30px; /* Match line-numbers width */
    width: calc(100% - 30px);
  }

  /* Touch Targets */
  button, 
  select, 
  .json-toggle,
  .escape-option label {
    min-height: 44px; /* Minimum touch target size */
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .json-toggle {
    width: 20px; /* Slightly larger for touch */
  }

  /* Status Bar */
  .status-bar {
    position: relative;
    flex-direction: column;
    gap: 5px;
    text-align: center;
    padding: 8px;
  }
}

@media screen and (max-width: 480px) {
  .header h1 {
    font-size: 16px;
  }
  
  .panel {
    height: 50vh !important;
  }
  
  .btn {
    padding: 4px 8px;
    font-size: 11px;
  }
}