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

:root {
  /* Dark theme with black and blue */
  --bg-primary: #000000;
  --bg-secondary: #0f1419;
  --bg-tertiary: #1a1f2e;
  --bg-card: #0d1117;
  --text-primary: #ffffff;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --border-color: #21262d;
  --accent-primary: #0ea5e9;
  --accent-secondary: #06b6d4;
  --accent-success: #22c55e;
  --accent-danger: #ef4444;
  --accent-warning: #f59e0b;
  --wire-red: #ef4444;
  --wire-black: #374151;
  --wire-blue: #3b82f6;
  --wire-yellow: #eab308;
  --wire-purple: #a855f7;
  --wire-gray: #9ca3af;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.5);
  --gradient-primary: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
  --gradient-secondary: linear-gradient(135deg, #1e40af 0%, #0ea5e9 100%);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: all 0.3s ease;
}

.container {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  padding: 2rem 0;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.logo-text h1 {
  font-size: 2.5rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
}

.logo-text .tagline {
  font-family: 'Ubuntu', cursive;
  /* hoặc font đẹp hơn */
  font-size: 1.0rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin: 0;
}


.logo img {
  width: 120px;
  height: auto;
  border-radius: 8px;
}

.logo h1 {
  font-size: 2.5rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.main-content {
  flex: 1;
  padding: 2rem;
}

.content-grid {
  display: grid;
  grid-template-columns: 30% 70%;
  gap: 2rem;
  height: calc(100vh - 200px);
}

/* Left Panel - Fixed */
.left-panel {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Right Panel - Scrollable */
.right-panel {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 2rem;
  border: 1px solid var(--border-color);
  height: 100%;
  overflow-y: auto;
}

/* Chip Selection */
.chip-selection h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  text-align: center;
  color: var(--accent-primary);
}

.chip-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chip-card {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.chip-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-primary);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.chip-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-primary);
}

.chip-card:hover::before {
  transform: scaleX(1);
}

.chip-card.selected {
  border-color: var(--accent-primary);
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(14, 165, 233, 0.1) 100%);
}

.chip-card.selected::before {
  transform: scaleX(1);
}

.chip-icon {
  width: 3rem;
  height: 3rem;
  background: var(--gradient-primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin: 0 auto 1rem;
  box-shadow: var(--shadow-md);
}

.chip-card h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Flash Section */
.flash-section {
  flex-shrink: 0;
}

.flash-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
}

.flash-controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Centered Button */
.centered-button {
  display: flex;
  justify-content: center;
  width: 100%;
  align-items: center;
}

/* Key Section */
.key-section {
  margin-top: auto;
}

.key-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
}

.key-text {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.btn-key {
  background: var(--gradient-primary);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
}

.btn-key:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Guide Section */
.guide-section h2 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 2rem;
  text-align: center;
  color: var(--accent-primary);
}

/* Tab Navigation */
.tab-navigation {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
  flex-wrap: wrap;
}

.tab-btn {
  background: var(--bg-tertiary);
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  flex: 1;
  text-align: center;
  min-width: 120px;
  font-size: 0.9rem;
}

.tab-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

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

/* Tab Content */
.tab-content {
  position: relative;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.5s ease;
}

/* Key Description Section */
.key-description-section {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.key-description-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
}

.key-description-card h3 {
  color: var(--accent-primary);
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.key-policy {
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.key-policy h4 {
  color: var(--accent-secondary);
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.key-policy ul {
  list-style: none;
  padding-left: 0;
}

.key-policy li {
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  padding-left: 1.5rem;
  position: relative;
}

.key-policy li::before {
  content: "✓";
  color: var(--accent-success);
  position: absolute;
  left: 0;
  font-weight: bold;
}

.pricing-section {
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.pricing-section h4 {
  color: var(--accent-warning);
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.price-card {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 1rem;
  display: inline-block;
}

.price-item {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.price-label {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

.price-value {
  color: var(--accent-primary);
  font-size: 1.5rem;
  font-weight: 700;
}

.purchase-section {
  text-align: center;
}

.purchase-section h4 {
  color: var(--accent-primary);
  margin-bottom: 1rem;
}

.purchase-section p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

/* Program Description Section */
.program-description-section {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.program-description-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
}

.program-description-card h3 {
  color: var(--accent-primary);
  font-size: 1.5rem;
  margin-bottom: 2rem;
  text-align: center;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.feature-item {
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 1.5rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.feature-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.feature-content h4 {
  color: var(--accent-secondary);
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.feature-content p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

.update-notice {
  background: var(--bg-tertiary);
  border: 1px solid var(--accent-primary);
  border-radius: 8px;
  padding: 1.5rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.update-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.update-content h4 {
  color: var(--accent-primary);
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.update-content p {
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Chip Type Tabs */
.chip-type-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.chip-tab-btn {
  background: var(--bg-tertiary);
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  flex: 1;
  text-align: center;
}

.chip-tab-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.chip-tab-btn.active {
  background: var(--accent-primary);
  color: white;
}

.chip-tab-content {
  display: none;
}

.chip-tab-content.active {
  display: block;
  animation: fadeIn 0.5s ease;
}

/* Wiring Section */
.wiring-section {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.wiring-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
}

.wiring-card h3 {
  color: var(--accent-primary);
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.wiring-card h4 {
  color: var(--accent-secondary);
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.wiring-card h5 {
  color: var(--accent-primary);
  font-size: 1.1rem;
  margin: 1.5rem 0 0.75rem;
}

/* Diagram Container */
.diagram-container {
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 2rem;
  text-align: center;
}

.wiring-diagram {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

/* Connection Table */
.connection-table {
  margin-bottom: 2rem;
}

.connection-table table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-tertiary);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.connection-table th,
.connection-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.connection-table th {
  background: var(--accent-primary);
  color: white;
  font-weight: 600;
}

.connection-table td {
  color: var(--text-secondary);
}

.wire-red {
  color: var(--wire-red);
  font-weight: 600;
}

.wire-black {
  color: var(--wire-black);
  font-weight: 600;
}

.wire-blue {
  color: var(--wire-blue);
  font-weight: 600;
}

.wire-yellow {
  color: var(--wire-yellow);
  font-weight: 600;
}

.wire-purple {
  color: var(--wire-purple);
  font-weight: 600;
}

.wire-gray {
  color: var(--wire-gray);
  font-weight: 600;
}

/* Important Notes */
.important-notes {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid var(--accent-warning);
  border-radius: 8px;
  padding: 1.5rem;
}

.important-notes h4 {
  color: var(--accent-warning);
  margin-bottom: 1rem;
}

.important-notes ul {
  list-style: none;
  padding-left: 0;
}

.important-notes li {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  padding-left: 1.5rem;
  position: relative;
}

.important-notes li::before {
  content: "⚠️";
  position: absolute;
  left: 0;
}

/* Activation Section */
.activation-section {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.activation-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
}

.activation-card h3 {
  color: var(--accent-primary);
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.activation-card h4 {
  color: var(--accent-secondary);
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

/* Step Container */
.step-container {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 2rem;
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 1.5rem;
}

.step-number {
  width: 2.5rem;
  height: 2.5rem;
  background: var(--accent-primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
  font-size: 1.1rem;
}

.step-content {
  flex: 1;
}

.step-content h4 {
  color: var(--accent-primary);
  margin-bottom: 0.5rem;
}

.step-content p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.step-content ul {
  list-style: none;
  padding-left: 0;
  margin-bottom: 1rem;
}

.step-content li {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  padding-left: 1.5rem;
  position: relative;
}

.step-content li::before {
  content: "→";
  color: var(--accent-primary);
  position: absolute;
  left: 0;
  font-weight: bold;
}

/* Image Placeholder */
.image-placeholder {
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  padding: 3rem 1rem;
  margin: 1rem 0;
  text-align: center;
}

.placeholder-text {
  color: var(--text-muted);
  font-style: italic;
}

/* Code Block */
.code-block {
  background: var(--bg-card);
  border-radius: 4px;
  padding: 1rem;
  margin: 1rem 0;
  font-family: "Courier New", monospace;
  color: var(--accent-primary);
  text-align: center;
  font-weight: 600;
}

/* Result Container */
.result-container {
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 1.5rem;
  margin-top: 2rem;
}

.result-container h4 {
  margin-bottom: 1rem;
}

.result-container p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.result-container.error h4 {
  color: var(--accent-danger);
}

.result-container.success h4 {
  color: var(--accent-success);
}

/* App Section */
.app-section {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.app-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
}

.app-card h3 {
  color: var(--accent-primary);
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.app-card h4 {
  color: var(--accent-secondary);
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

/* App Download */
.app-download {
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  text-align: center;
}

.app-stores {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin: 1.5rem 0;
}

.app-store-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem 2rem;
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
}

.app-store-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-primary);
}

.app-store-icon {
  font-size: 1.5rem;
}

.qr-placeholder {
  background: white;
  width: 150px;
  height: 150px;
  margin: 1rem auto;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* App Setup */
.app-setup {
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.setup-steps {
  list-style: none;
  padding-left: 0;
  counter-reset: step-counter;
}

.setup-steps li {
  margin-bottom: 1.5rem;
  padding-left: 2.5rem;
  position: relative;
}

.setup-steps li::before {
  counter-increment: step-counter;
  content: counter(step-counter);
  position: absolute;
  left: 0;
  top: 0;
  width: 1.75rem;
  height: 1.75rem;
  background: var(--accent-primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.setup-steps li strong {
  color: var(--accent-primary);
  display: block;
  margin-bottom: 0.25rem;
}

.setup-steps li p {
  color: var(--text-secondary);
}

/* App Interface */
.app-interface {
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.interface-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.interface-item {
  text-align: center;
}

.interface-placeholder {
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  padding: 3rem 1rem;
  margin-bottom: 1rem;
}

.interface-item p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* App Troubleshooting */
.app-troubleshooting {
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 1.5rem;
}

.trouble-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.trouble-item {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 1.5rem;
}

.trouble-item h5 {
  color: var(--accent-primary);
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.trouble-item ul {
  list-style: none;
  padding-left: 0;
}

.trouble-item li {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  padding-left: 1.5rem;
  position: relative;
  font-size: 0.9rem;
}

.trouble-item li::before {
  content: "→";
  color: var(--accent-primary);
  position: absolute;
  left: 0;
  font-weight: bold;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 1rem;
}

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

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ESP Web Tools Button Styling */
esp-web-install-button {
  --esp-tools-button-color: white;
  --esp-tools-button-background: var(--accent-primary);
  --esp-tools-button-border-radius: 8px;
  --esp-tools-button-padding: 0.75rem 1.5rem;
  --esp-tools-button-font-weight: 600;
  width: 100%;
}

.invisible {
  visibility: hidden;
}

/* Status Section */
.status-section {
  flex-shrink: 0;
}

.status-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
}

.status-icon {
  width: 3rem;
  height: 3rem;
  background: var(--gradient-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin: 0 auto 1rem;
  animation: pulse 2s infinite;
}

.status-card h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--accent-primary);
}

.status-card p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

/* Footer */
.footer {
  padding: 2rem 0;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  margin-top: 2rem;
}

.footer-content {
  text-align: center;
}

.footer-content h3 {
  color: var(--accent-primary);
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.footer-link {
  color: var(--text-secondary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: color 0.3s ease;
  font-weight: 500;
}

.footer-link:hover {
  color: var(--accent-primary);
}

.footer-icon {
  font-size: 1.2rem;
}

.footer-text {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Animations */
@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.5s ease-out;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .content-grid {
    grid-template-columns: 1fr;
    height: auto;
  }

  .left-panel,
  .right-panel {
    height: auto;
    max-height: none;
  }

  .trouble-grid {
    grid-template-columns: 1fr;
  }

  .tab-navigation {
    flex-direction: column;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .main-content {
    padding: 1rem;
  }

  .logo h1 {
    font-size: 2rem;
  }

  .footer-links {
    flex-direction: column;
    gap: 1rem;
    align-items: center;
  }

  .footer-content {
    padding: 0 1rem;
  }

  .footer-text {
    padding: 0 1rem;
  }

  .step-container {
    flex-direction: column;
  }

  .step-number {
    align-self: center;
  }

  .interface-grid {
    grid-template-columns: 1fr;
  }

  .tab-navigation {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .tab-btn {
    width: 100%;
    min-width: auto;
  }

  .chip-type-tabs {
    flex-wrap: wrap;
  }

  .feature-item {
    flex-direction: column;
    text-align: center;
  }

  .update-notice {
    flex-direction: column;
    text-align: center;
  }
}

.update-section {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.update-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
}

.update-card h3 {
  color: var(--accent-primary);
  font-size: 1.5rem;
  margin-bottom: 1rem;
  text-align: center;
}

.update-card ul {
  list-style: none;
  padding-left: 0;
}

.update-card li {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  padding-left: 1.5rem;
  position: relative;
}

.update-card li::before {
  content: "✔️";
  position: absolute;
  left: 0;
  color: var(--accent-success);
}

.feature-request-form {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  margin-top: 2rem;
}

.feature-request-form h4 {
  color: var(--accent-primary);
  margin-bottom: 1rem;
}

.feature-request-form p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
}

#formMessage {
  margin-top: 1rem;
  font-weight: 600;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* Fix image responsiveness in activation tab */
.image-placeholder img {
  max-width: 100%;
  height: auto;
}

/* Popup Warning Overlay */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  padding: 1rem;
}

.popup-box {
  background: var(--bg-card);
  border: 1px solid var(--accent-warning);
  border-radius: 12px;
  padding: 2rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.3s ease-out;
  position: relative;
}

/* Close Button Styling - ĐÂY LÀ PHẦN QUAN TRỌNG */
.close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2rem;
  height: 2rem;
  background: var(--accent-danger);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: bold;
  transition: all 0.3s ease;
  z-index: 10000;
}

.close-btn:hover {
  background: #dc2626;
  transform: scale(1.1);
}

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

.popup-box h3 {
  color: var(--accent-warning);
  margin-bottom: 1rem;
  margin-top: 1rem;
  /* Thêm margin-top để tránh đè lên nút X */
}

.popup-box p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.6;
  font-size: 0.95rem;
}

/* Custom Checkbox */
.custom-checkbox {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  user-select: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
  justify-content: flex-start;
}

.custom-checkbox input {
  display: none;
}

.custom-checkbox .checkmark {
  width: 20px;
  height: 20px;
  border: 2px solid var(--accent-warning);
  border-radius: 4px;
  display: inline-block;
  position: relative;
  background: var(--bg-card);
  flex-shrink: 0;
}

.custom-checkbox input:checked+.checkmark::after {
  content: "✔";
  position: absolute;
  top: -2px;
  left: 3px;
  color: var(--accent-warning);
  font-size: 1rem;
  font-weight: bold;
}

.checkbox-label-text {
  flex: 1;
  color: var(--text-secondary);
}

.main-guide-tabs {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.main-guide-tab-btn {
  background: var(--bg-tertiary);
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.main-guide-tab-btn.active {
  background: var(--accent-primary);
  color: white;
}

.main-guide-tab-content {
  display: none;
}

.main-guide-tab-content.active {
  display: block;
}

/* FW và CHIP chia đôi chiều ngang */
.fw-grid-horizontal,
.chip-grid-horizontal {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-top: 1rem;
}

.fw-button,
.chip-button {
  flex: 1 1 48%;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.fw-button::before,
.chip-button::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 3px;
  width: 100%;
  background: var(--gradient-primary);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.fw-button:hover,
.chip-button:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
  color: white;
}

.fw-button:hover::before,
.chip-button:hover::before {
  transform: scaleX(1);
}

.fw-button.active,
.chip-button.active {
  border-color: var(--accent-primary);
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(14, 165, 233, 0.1) 100%);
}

.fw-button.active::before,
.chip-button.active::before {
  transform: scaleX(1);
}

.oled-button {
  flex: 1 1 48%;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.oled-button::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 3px;
  width: 100%;
  background: var(--gradient-primary);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.oled-button:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
  color: white;
}

.oled-button:hover::before {
  transform: scaleX(1);
}

.oled-button.active {
  border-color: var(--accent-primary);
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(14, 165, 233, 0.1) 100%);
}

.oled-button.active::before {
  transform: scaleX(1);
}

/* Additional styles for firmware checking and not available messages */
.firmware-checking {
  background: var(--bg-card);
  border: 2px solid var(--accent-primary);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  animation: fadeIn 0.5s ease;
}

.checking-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  animation: spin 2s linear infinite;
}

.firmware-checking p {
  color: var(--text-secondary);
  margin: 0;
  font-size: 0.9rem;
}

.firmware-not-available {
  background: var(--bg-card);
  border: 2px solid var(--accent-warning);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  animation: fadeIn 0.5s ease;
}

.not-available-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  animation: pulse 2s infinite;
}

.firmware-not-available h4 {
  color: var(--accent-warning);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.firmware-not-available p {
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.firmware-not-available p strong {
  color: var(--accent-primary);
  font-weight: 600;
}

.coming-soon {
  color: var(--accent-success) !important;
  font-weight: 600;
  font-size: 0.95rem;
}

/* Animations */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.05);
    opacity: 0.8;
  }
}

/* Main guide tabs (MochiNav / Xiaozhi) */
.main-guide-tab-content {
  display: none;
}

.main-guide-tab-content.active {
  display: block;
  animation: fadeIn 0.5s ease;
}

/* === Tab 4 License - Dark theme === */
.license-scope {
  color: var(--text, #e5eef7);
  padding-top: 8px;
}

.license-scope .header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 16px;
}

.license-scope #title {
  margin: 0;
  font-size: 28px;
  color: var(--heading, #e6f0ff);
}

.license-scope .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--chip, #1f2937);
  color: var(--muted-fg, #cbd5e1);
  border: 1px solid var(--chip-border, #2a3646);
  white-space: nowrap;
}

.license-scope .badge.muted {
  opacity: .95;
}

.license-scope .badge.ok {
  background: #146c43;
  color: #fff;
  border-color: #146c43;
}

.license-scope .row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.license-scope input,
.license-scope textarea {
  flex: 1;
  background: var(--bg-input, #0f172a);
  color: var(--text, #e5eef7);
  border: 1px solid var(--border, #2a3646);
  border-radius: 12px;
  padding: 12px 14px;
}

.license-scope input::placeholder,
.license-scope textarea::placeholder {
  color: #9aa7b2;
}

.license-scope button {
  height: 40px;
  line-height: 1;
  padding: 10px 14px;
  font-weight: 600;
  border-radius: 12px;
  border: 1px solid var(--btn-border, #2a3646);
  background: var(--btn-bg, #1f2937);
  color: var(--btn-fg, #e5e7eb);
  transition: transform .02s ease, filter .15s ease;
}

.license-scope button:hover {
  filter: brightness(1.08);
}

.license-scope button:active {
  transform: translateY(1px);
}

.license-scope button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.license-scope #btnConnect {
  background: #0ea5e9;
  border-color: #0ea5e9;
  color: #fff;
}

.license-scope #btnActivate {
  background: #0284c7;
  border-color: #0284c7;
  color: #fff;
}

.license-scope #btnReboot {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}

.license-scope #log {
  margin-top: 12px;
  padding: 16px;
  min-height: 180px;
  max-height: 320px;
  overflow: auto;
  border-radius: 12px;
  background: var(--bg-card, #0e1620);
  border: 1px solid var(--border, #2a3646);
  color: #d1e7ff;
}

.license-scope hr {
  border: 0;
  height: 1px;
  background: var(--border, #2a3646);
  margin: 18px 0;
}

@media (max-width:560px) {
  .license-scope #title {
    font-size: 22px;
  }

  .license-scope .badge {
    height: 24px;
    font-size: 11px;
    padding: 0 8px;
  }
}

.iv.hidden {
  display: none;
}

/* Overlay */
.iv {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 9999;
  user-select: none;
  touch-action: none;
  /* để xử lý pinch/drag bằng Pointer Events */
}

/* Thanh công cụ */
.iv__toolbar {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  color: #fff;
  font: 500 14px/1.2 system-ui, sans-serif;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0));
  pointer-events: none;
}

.iv__btn {
  margin-left: auto;
  pointer-events: auto;
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
}

.iv__btn:hover {
  background: rgba(255, 255, 255, .12);
}

.iv__hint {
  opacity: .85;
}

/* Sân khấu giữ ảnh */
.iv__stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  cursor: grab;
}

.iv__stage.dragging {
  cursor: grabbing;
}

/* Ảnh được transform */
#ivImg {
  will-change: transform;
  transform-origin: 50% 50%;
  max-width: none;
  max-height: none;
  /* để tự tính scale */
  image-rendering: -webkit-optimize-contrast;
  -ms-interpolation-mode: nearest-neighbor;
}

/* --- Parts / Links catalogue --- */
.links-section {
  display: block;
}

.links-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.links-card h3 {
  text-align: center;
  color: var(--accent-primary);
  font-size: 1.4rem;
  margin-bottom: 1rem;
}

.parts-group + .parts-group {
  margin-top: 1.25rem;
}

.parts-group h4 {
  color: var(--accent-secondary);
  font-size: 1.05rem;
  margin: 0.75rem 0 0.75rem;
}

.parts-list {
  list-style: none;
  padding-left: 0;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.part-link {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 0.75rem;
  align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  text-decoration: none;
  transition: all .2s ease;
}

.part-title {
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.25;
}

.part-note {
  color: var(--text-secondary);
  font-size: 0.88rem;
  grid-column: 1 / span 1;
}

.part-go {
  color: var(--accent-primary);
  font-weight: 700;
  white-space: nowrap;
}

.part-link:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
  background: linear-gradient(135deg, var(--bg-tertiary) 0%, rgba(14,165,233,0.08) 100%);
}

@media (max-width: 560px) {
  .parts-list {
    grid-template-columns: 1fr;
  }
}
.version-item { display: grid; gap: 4px; }
.version-name { font-weight: 700; }
.version-desc {
  font-size: 0.9rem;
  line-height: 1.3;
  opacity: 0.9;
}
.version-desc a { text-decoration: underline; }
