:root {
  --primary: #1e40af;
  --primary-dark: #1e3a8a;
  --primary-light: #eff6ff;
  --accent: #dc2626;
  --accent-dark: #b91c1c;
  --bg-body: #f1f5f9;
  --surface: #ffffff;
  --border-color: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --success: #16a34a;
  --radius: 12px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  margin: 0;
  padding: 16px 8px;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

.wrap {
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
}

/* ── Modern App Header ── */
.app-header {
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
  color: #ffffff;
  padding: 22px 18px;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: 0 10px 25px -5px rgba(30, 58, 138, 0.25);
  margin-bottom: 20px;
  word-break: break-word;
}

.app-header h1 {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.app-header p.sub {
  margin: 6px 0 0 0;
  font-size: 0.88rem;
  color: #dbeafe;
  font-weight: 400;
}

.app-header .reset-link {
  margin: 10px 0 0;
}

.app-header .reset-link a {
  font-size: 0.8rem;
  font-weight: 600;
  color: #fee2e2;
  background: rgba(220, 38, 38, 0.35);
  border: 1px solid rgba(248, 113, 113, 0.5);
  padding: 4px 12px;
  border-radius: 999px;
  display: inline-block;
  text-decoration: none;
  transition: all 0.2s ease;
}

.app-header .reset-link a:hover {
  background: rgba(220, 38, 38, 0.6);
  color: #fff;
}

/* ── Wizard Steps ── */
.steps {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border-color);
}

.steps li span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--border-color);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
}

.steps li.active {
  color: var(--primary-dark);
  border-color: var(--primary);
  background: var(--primary-light);
}

.steps li.active span {
  background: var(--primary);
}

.steps li.done {
  color: var(--success);
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.steps li.done span {
  background: var(--success);
}

/* ── Card Containers ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border-color);
  width: 100%;
}

.card h2 {
  margin: 0 0 16px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
  border-bottom: 2px solid var(--primary-light);
  padding-bottom: 8px;
}

.card h3 {
  font-size: 1rem;
  margin: 18px 0 10px;
  color: #0f172a;
}

/* ── Form Fields ── */
label {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 12px;
}

input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 8px 12px;
  font-size: 0.92rem;
  border: 2.5px solid #cbd5e1;
  border-radius: 8px;
  font-family: inherit;
  color: var(--text-main);
  background: #fff;
  transition: all 0.2s ease-in-out;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

input[readonly] {
  background: #f1f5f9;
  color: var(--text-muted);
}

.grid2, .grid3, .grid4 {
  display: grid;
  gap: 0 14px;
}

.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: -4px 0 14px;
  line-height: 1.45;
}

/* ── Action Buttons & Downloads Layout ── */
.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.preview-actions-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
  width: 100%;
}

.dl-group {
 
  gap: 10px;
  flex-wrap: wrap;
  
}

button, .btn, .btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  border: none;
  min-height: 42px;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

button, .btn {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #fff;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.25);
}

button:hover, .btn:hover {
  background: linear-gradient(135deg, #047857 0%, #059669 100%);
  box-shadow: 0 6px 14px rgba(16, 185, 129, 0.35);
  transform: translateY(-1px);
}

/* Redesigned Back & Edit Button: Light Warm Slate/Indigo Accent */
.btn-secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1.5px solid #cbd5e1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-secondary:hover {
  background: #e2e8f0;
  color: #0f172a;
  border-color: #94a3b8;
}

/* ── Alerts ── */
.alert {
  background: #fee2e2;
  border: 1px solid #f87171;
  color: #b91c1c;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 0.88rem;
}

.alert ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

/* ── Preview Grid & Information ── */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 14px;
  background: var(--primary-light);
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 18px;
  font-size: 0.85rem;
}

.preview-grid b {
  color: var(--primary-dark);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 2px;
}

/* ── Tables ── */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.prev-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.88rem;
  white-space: nowrap;
  min-width: 700px;
}

.prev-table th {
  background: #1e3a8a;
  color: #ffffff;
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  text-align: right;
}

.prev-table th:first-child {
  text-align: left;
}

.prev-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  text-align: right;
  color: #1e293b;
  font-weight: 500;
}

.prev-table td:first-child {
  text-align: left;
}

.prev-table tbody tr:nth-child(even) {
  background-color: #f8fafc;
}

.prev-table tbody tr:hover {
  background-color: #f1f5f9;
}

.prev-table tfoot td {
  background-color: #0f172a;
  color: #ffffff;
  font-weight: 700;
}

.prev-table tfoot td b {
  color: #4ade80;
  font-size: 0.95rem;
}

/* ── Informational Guide ── */
.info-wrap {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px dashed var(--border-color);
}

.info-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.info-nav a {
  font-size: 0.78rem;
  padding: 6px 12px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  text-decoration: none;
  font-weight: 600;
  border: 1px solid var(--border-color);
}

.info-nav a:hover {
  background: var(--primary-dark);
  color: #fff;
  border-color: var(--primary-dark);
}

.info-section {
  margin-bottom: 24px;
}

.info-section h3 {
  font-size: 1.05rem;
  color: var(--primary-dark);
  margin: 0 0 8px;
  scroll-margin-top: 16px;
}

.info-section h4 {
  font-size: 0.92rem;
  margin: 14px 0 4px;
  color: var(--text-main);
}

.info-section p {
  font-size: 0.86rem;
  color: #334155;
  margin: 0 0 10px;
  line-height: 1.55;
}

.info-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 0.84rem;
}

.info-table th, .info-table td {
  border: 1px solid var(--border-color);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.info-table th {
  background: #f8fafc;
  color: var(--primary-dark);
  font-weight: 600;
}

.faq details {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 6px;
  background: #fff;
}

.faq summary {
  font-weight: 600;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-main);
}

.faq details p {
  margin: 6px 0 0;
  font-size: 0.84rem;
  color: #475569;
}

.howto-list {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 0;
}

.howto-list li {
  counter-increment: step;
  position: relative;
  padding-left: 32px;
  margin-bottom: 10px;
  font-size: 0.86rem;
  line-height: 1.45;
}

.howto-list li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary-dark);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-slot {
  margin: 16px auto;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 8px;
  text-align: center;
  color: #94a3b8;
  font-size: 0.78rem;
  width: 100%;
}

.done-bar {
  margin-top: 18px;
  padding: 14px;
  border-radius: 8px;
  background: var(--primary-light);
  border: 1px solid #bfdbfe;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.done-bar p {
  margin: 0;
  font-size: 0.84rem;
  color: #1e3a8a;
}

/* ── Light Gray Footer ── */
.app-footer {
  background: #e2e8f0;
  color: #475569;
  padding: 14px;
  border-radius: var(--radius);
  text-align: center;
  font-size: 0.85rem;
  font-weight: 500;
  margin-top: 24px;
  border: 1px solid #cbd5e1;
}

.app-footer a {
  color: var(--primary-dark);
  font-weight: 700;
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

/* ── Screen Width <= 768px Strict Adjustments ── */
@media only screen and (max-width: 768px) {
  body {
    padding: 8px 4px;
  }
  .app-header {
    padding: 16px 12px;
    margin-bottom: 12px;
  }
  .app-header h1 {
    font-size: 1.15rem;
  }
  .card {
    padding: 14px 10px;
  }
  .grid2, .grid3, .grid4 {
    grid-template-columns: 1fr;
    gap: 0;
  }
  label {
    margin-bottom: 10px;
    font-size: 0.84rem;
  }
  input, select, textarea {
    padding: 8px 10px;
    font-size: 0.9rem;
  }
  
  /* Generic form action bars */
  .actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .actions > span {
    display: none;
  }
  .actions .btn, 
  .actions button, 
  .actions .btn-secondary {
    width: 100%;
    margin: 4px 0;
  }

  /* Specific Preview Step 4 Mobile Stacking */
  .preview-actions-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }

  .preview-actions-container .btn-secondary {
    width: 100%;
    order: 1;
    margin-bottom: 4px;
  }

  .preview-actions-container .ad-slot-preview {
    order: 2;
    margin: 8px 0;
    width: 100%;
  }

  .preview-actions-container .dl-group {
    order: 3;
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }

  .preview-actions-container .dl-group .btn {
    width: 100%;
    margin: 0;
  }

  .preview-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
  }
  .steps {
    gap: 4px;
  }
  .steps li {
    font-size: 0.72rem;
    padding: 4px 8px;
  }
  .done-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .done-bar .btn-secondary {
    width: 100%;
  }
  .app-footer {
    padding: 12px 8px;
    font-size: 0.8rem;
  }
}