:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --green: #059669;
  --green-bg: #ecfdf5;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --orange: #d97706;
  --orange-bg: #fffbeb;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 500px at 10% -10%, #e0e7ff 0%, transparent 60%), var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
}

code {
  font-family: "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: 0.92em;
  background: #f3f4f6;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  word-break: break-all;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.hero {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}

.hero-icon {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.5px;
  box-shadow: 0 12px 24px -10px rgba(79, 70, 229, 0.7);
}

.hero-icon span { opacity: 0.55; margin: 0 1px; }

.hero h1 {
  margin: 0 0 4px;
  font-size: 26px;
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 780px;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 8px 30px -24px rgba(15, 23, 42, 0.35);
}

.layout .card { margin-bottom: 0; }

.card-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.card-head h2 {
  margin: 0 0 2px;
  font-size: 16.5px;
}

.card-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.step {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--blue-bg);
  color: var(--blue);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

textarea,
input[type="url"],
input[type="text"],
input[type="number"],
input:not([type]) {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: #fbfcfe;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
  min-height: 132px;
  resize: vertical;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
}

textarea:focus,
input:focus {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.14);
  background: #fff;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.field input {
  font-weight: 400;
  color: var(--text);
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.hint {
  color: var(--muted);
  font-size: 12.5px;
}

.security {
  margin: 10px 0 0;
  color: #92400e;
  background: var(--orange-bg);
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
}

.sa-box {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--blue-bg);
  border: 1px solid #bfdbfe;
  border-radius: 10px;
}

.sa-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  min-width: 0;
}

.sa-info code { background: #fff; }

.advanced {
  margin-top: 14px;
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}

.advanced summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.grid2 label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--muted);
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: #eef2ff;
  color: var(--primary);
  transition: background 0.15s, transform 0.05s, opacity 0.15s;
  white-space: nowrap;
}

.btn:hover { background: #e0e7ff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn.primary {
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  padding: 11px 24px;
  box-shadow: 0 10px 20px -12px rgba(79, 70, 229, 0.9);
}

.btn.primary:hover { background: linear-gradient(135deg, var(--primary-dark), #6d28d9); }

.btn.ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.btn.ghost:hover { background: #f9fafb; }

a.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.btn.export {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}

.btn.export:hover { background: #d1fae5; }

.btn.danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.btn.danger:hover { background: #fee2e2; }

.btn.tiny {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 8px;
}

.run-card { margin-top: 18px; }
.run-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }

.alert {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
}

.alert.error {
  background: var(--red-bg);
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.hidden { display: none !important; }

.progress-wrap { margin-top: 16px; }

.progress-head {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: #eef2ff;
  overflow: hidden;
}

.fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #4f46e5, #8b5cf6);
  transition: width 0.35s ease;
}

.meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12.5px;
}

.stats {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.stat {
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: #f9fafb;
}

.stat.valid { background: var(--green-bg); border-color: #a7f3d0; color: var(--green); }
.stat.invalid { background: var(--red-bg); border-color: #fecaca; color: var(--red); }
.stat.error { background: var(--orange-bg); border-color: #fde68a; color: var(--orange); }

#resultSection { margin-top: 18px; }

.table-wrap {
  max-height: 560px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.8px;
}

thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  z-index: 1;
}

tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}

tbody tr:hover { background: #fafbff; }

td.link-cell {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td.link-cell a { color: var(--blue); text-decoration: none; }
td.link-cell a:hover { text-decoration: underline; }

td.content-cell {
  max-width: 330px;
  white-space: pre-wrap;
  word-break: break-word;
}

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
}

.pill.valid { background: var(--green-bg); color: var(--green); }
.pill.invalid { background: var(--red-bg); color: var(--red); }
.pill.error { background: var(--orange-bg); color: var(--orange); }
.pill.running { background: var(--blue-bg); color: var(--blue); }

.platform {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  background: #f3f4f6;
  color: #374151;
}

.platform.facebook { background: #eff6ff; color: #1d4ed8; }
.platform.youtube { background: #fef2f2; color: #b91c1c; }

#log {
  max-height: 320px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  background: #0f172a;
  color: #cbd5e1;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.55;
  font-family: "Cascadia Code", Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  color: #94a3b8;
  font-size: 11.5px;
  margin-top: 26px;
}

.footer code { font-size: 10.5px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .hero { align-items: flex-start; }
  .hero h1 { font-size: 22px; }
  .grid2 { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .page { padding: 18px 12px 40px; }
  .card { padding: 16px; }
  .hero-icon { width: 52px; height: 52px; font-size: 15px; }
  .sa-box { flex-direction: column; align-items: flex-start; }
}
