:root {
  --purple-900: #3b1d6e;
  --purple-700: #6d28d9;
  --purple-600: #7c3aed;
  --purple-100: #f3e8ff;
  --purple-50: #faf5ff;
  --white: #ffffff;
  --text: #2e1a47;
  --muted: #6b5b80;
  --error: #b42318;
  --error-bg: #fff1f0;
  --success: #067647;
  --success-bg: #ecfdf3;
  --shadow: 0 16px 40px rgba(109, 40, 217, 0.12);
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, #e9d5ff 0%, transparent 42%),
    linear-gradient(180deg, var(--purple-50) 0%, var(--white) 100%);
}

.page {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 18px;
}

.nav a {
  color: var(--purple-700);
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
}

.nav a[aria-current="page"] { color: var(--purple-900); text-decoration: underline; }
.nav a:hover { text-decoration: underline; }

h1 {
  margin: 0 0 10px;
  color: var(--purple-900);
  font-size: clamp(2rem, 5vw, 2.8rem);
  line-height: 1.15;
}

.subtitle {
  margin: 0 0 24px;
  max-width: 720px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.panel, .info-section, .step-card {
  background: var(--white);
  border: 1px solid #e9d8fd;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel { margin-bottom: 16px; padding: 22px; }

.panel h2, .info-section h2, .how-to-section h2 {
  margin: 0 0 12px;
  color: var(--purple-900);
  font-size: clamp(1.25rem, 3vw, 1.6rem);
  line-height: 1.3;
}

.editor-label { display: block; margin-bottom: 8px; font-weight: 700; color: var(--purple-900); }

.editor, select, .file-input {
  width: 100%;
  border: 1px solid #ddc8f5;
  border-radius: 14px;
  background: #fdfbff;
  color: var(--text);
  font: inherit;
}

.editor {
  min-height: 280px;
  resize: vertical;
  padding: 16px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.95rem;
  line-height: 1.55;
}

select, .file-input { padding: 12px 14px; }

.editor:focus, select:focus, .file-input:focus, .btn:focus-visible, .check:focus-within, .nav a:focus-visible, .table-wrap:focus-visible, .info-section a:focus-visible {
  outline: 3px solid #d8b4fe;
  outline-offset: 2px;
}

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

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary { color: var(--white); background: var(--purple-700); }
.btn-secondary { color: var(--purple-700); background: var(--purple-100); }
.btn-ghost { color: var(--purple-900); background: var(--white); border: 1px solid #e4d4f5; }

.file-btn { display: inline-flex; align-items: center; }
.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.options { display: grid; grid-template-columns: minmax(180px, 240px) 1fr 1fr; gap: 14px; align-items: end; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  color: var(--purple-900);
  font-weight: 700;
}

.hint, .count, .empty { color: var(--muted); line-height: 1.5; }
.hint { margin: 12px 0 0; }

.preview-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.count { margin: 0 0 12px; }

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid #eadcff;
  border-radius: 14px;
  background: #fdfbff;
}

.preview { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.preview th, .preview td {
  padding: 10px 12px;
  border-bottom: 1px solid #eadcff;
  text-align: left;
  white-space: nowrap;
  vertical-align: top;
}
.preview th { color: var(--purple-900); background: var(--purple-100); }

.empty { margin: 0; padding: 16px; }
.status { min-height: 1.4em; margin: 14px 0 0; line-height: 1.5; }
.status.error, .status.success { border-radius: 10px; padding: 10px 12px; }
.status.error { color: var(--error); background: var(--error-bg); }
.status.success { color: var(--success); background: var(--success-bg); }

.info-section, .how-to-section { margin-top: 24px; }
.info-section { padding: 22px; }
.info-section p, .step-card p { margin: 0 0 12px; color: var(--muted); font-size: 1.02rem; line-height: 1.7; }
.info-section h3 { margin: 16px 0 8px; color: var(--purple-700); font-size: 1.05rem; }
.info-section a { color: var(--purple-700); font-weight: 700; }
.step-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.step-card { padding: 20px; }
.step-card h3 { margin: 0 0 8px; color: var(--purple-700); font-size: 1.05rem; }
.step-card p { margin: 0; }

.json-example {
  margin: 8px 0 16px;
  padding: 16px;
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid #eadcff;
  border-radius: 14px;
  background: #fdfbff;
  color: var(--text);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.92rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.footer { margin-top: 18px; color: var(--muted); font-size: 0.9rem; }

@media (max-width: 800px) {
  .page { width: min(100% - 24px, 1100px); padding: 24px 0 36px; }
  .options, .step-grid { grid-template-columns: 1fr; }
  .panel, .info-section, .step-card { padding: 16px; }
  .btn, .file-btn, select, .file-input { width: 100%; }
  .editor { min-height: 220px; }
}
