:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1a1f36;
  --muted: #5d6476;
  --border: #e2e6f0;
  --primary: #3b6df6;
  --primary-dark: #2f56c5;
  --accent: #f1f4ff;
}

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

body {
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app {
  max-width: 1100px;
  margin: 40px auto 80px;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.app__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 8px;
}

h1 {
  font-size: 32px;
  margin-bottom: 12px;
}

.subtitle {
  color: var(--muted);
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

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

.pager {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.pager .hint {
  margin: 0;
}

.collapsible > summary {
  list-style: none;
  cursor: pointer;
}

.collapsible > summary::-webkit-details-marker {
  display: none;
}

.collapse-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.collapse-text {
  white-space: nowrap;
}

.collapsible[open] .collapse-text--closed {
  display: none;
}

.collapsible:not([open]) .collapse-text--open {
  display: none;
}

.collapsible[open] .collapse-icon {
  transform: rotate(90deg);
}

.collapse-icon {
  display: inline-block;
  font-size: 16px;
  transition: transform 0.2s ease;
}

.server-config {
  display: flex;
  gap: 8px;
  align-items: center;
}

.server-config select {
  padding: 8px 36px 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--accent);
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-dark);
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--primary-dark) 50%),
    linear-gradient(135deg, var(--primary-dark) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.select.small {
  font-size: 12px;
  gap: 8px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.field label {
  font-weight: 600;
  margin-bottom: 8px;
  display: block;
}

.field input[type="file"] {
  width: 100%;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #f9faff;
}

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

.options {
  margin-top: 16px;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.checkbox {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 14px;
  color: var(--muted);
}

.select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--accent);
  font-size: 13px;
  color: var(--primary-dark);
  font-weight: 600;
}

.select select {
  padding: 6px 26px 6px 6px;
  border-radius: 999px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-dark);
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--primary-dark) 50%),
    linear-gradient(135deg, var(--primary-dark) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.select select:focus {
  outline: none;
}

.order {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
}

.order__item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fdfdff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.order__item.dragging {
  opacity: 0.6;
}

.order__item.over {
  border-color: var(--primary);
  box-shadow: 0 8px 18px rgba(59, 109, 246, 0.18);
}

.order__handle {
  font-size: 18px;
  color: var(--muted);
  cursor: grab;
}

.order__title {
  font-weight: 600;
}

.order__meta {
  font-size: 12px;
  color: var(--muted);
}

.header-input {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 13px;
  width: 100%;
}

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

.regex-grid input {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 12px;
}

.empty-value {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 12px;
  width: 100%;
}

.order__actions {
  display: flex;
  gap: 8px;
}

button {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

button:active {
  transform: scale(0.98);
}

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

button.primary:hover {
  background: var(--primary-dark);
}

button.ghost {
  background: var(--accent);
  color: var(--primary-dark);
}

button.ghost.small {
  padding: 6px 12px;
  font-size: 12px;
}

label.ghost.small {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--primary-dark);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.preview {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  max-height: 320px;
}

.preview table {
  width: 100%;
  border-collapse: collapse;
  min-width: 500px;
}

.preview th,
.preview td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
}

.preview th {
  background: #f8f9ff;
  position: sticky;
  top: 0;
}

.preview tbody tr:nth-child(even) {
  background: #fafbff;
}

@media (max-width: 720px) {
  .panel__header {
    flex-direction: column;
    align-items: flex-start;
  }

  .panel__actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }

  .server-config {
    width: 100%;
    flex-wrap: wrap;
  }

  .server-config select {
    width: 100%;
  }

  .config-row {
    width: 100%;
  }
}
