:root {
  --color-bg: #f7f7f8;
  --color-surface: #ffffff;
  --color-border: #d8d8dc;
  --color-text: #1c1c1f;
  --color-muted: #6b6b70;
  --color-accent: #2454ff;
  --color-error: #c62828;
  --color-error-bg: #fdecea;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.4;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

h1 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

h2 {
  font-size: 1.1rem;
  margin: 0 0 8px;
}

.hint {
  color: var(--color-muted);
  margin-top: 0;
}

.drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  background: var(--color-surface);
  margin: 16px 0;
  transition: border-color 0.15s ease, background 0.15s ease;
}

@media (prefers-reduced-motion: reduce) {
  .drop-zone {
    transition: none;
  }
}

.drop-zone.dragover {
  border-color: var(--color-accent);
  background: #eef2ff;
}

.drag-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  background: rgba(36, 84, 255, 0.15);
  border: 4px dashed var(--color-accent);
  pointer-events: none;
}

.drag-overlay.active {
  display: flex;
}

.drag-overlay p {
  background: var(--color-surface);
  padding: 16px 28px;
  border-radius: var(--radius);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--color-accent);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.order-error {
  color: var(--color-error);
  font-weight: 600;
  min-height: 1.2em;
  margin: 8px 0;
}

.group-controls {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
}

.group-controls-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 12px;
  align-items: center;
}

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

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.group-controls-row label,
.field-label {
  font-size: 0.9rem;
  color: var(--color-muted);
}

.group-controls-row + .group-controls-row {
  margin-top: 12px;
}

.group-controls-toprow {
  justify-content: space-between;
}

.select-all-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
}

.select-all-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

#group-multiplier {
  width: 6em;
}

.material-control {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.material-custom-input {
  width: 10em;
}

section {
  margin: 24px 0;
}

.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-hint {
  color: var(--color-muted);
  font-style: italic;
}

.file-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.file-card.has-error {
  border-color: var(--color-error);
  background: var(--color-error-bg);
}

.file-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  word-break: break-word;
}

.file-card-header input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.file-card-header span {
  flex: 1;
}

.file-card-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 10px;
  align-items: center;
}

.file-card-fields > div {
  min-width: 0;
  max-width: 100%;
}

.file-card-fields label {
  font-size: 0.85rem;
  color: var(--color-muted);
  display: block;
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stepper button {
  min-width: 44px;
  min-height: 44px;
}

.stepper input {
  width: 3.5em;
  text-align: center;
  -moz-appearance: textfield;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.preview {
  margin-top: 8px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.9rem;
  color: var(--color-accent);
  word-break: break-all;
}

.file-error {
  color: var(--color-error);
  font-size: 0.9rem;
  margin-top: 6px;
}

.remove-button {
  background: var(--color-error-bg);
  border: 1px solid var(--color-error);
  color: var(--color-error);
  border-radius: 6px;
  min-height: 36px;
  padding: 4px 10px;
  cursor: pointer;
  flex-shrink: 0;
  font-weight: 600;
}

.remove-button:hover {
  background: #fbdad7;
}

.reset-button {
  background: #fff4e0;
  border: 1px solid #b5780a;
  color: #8a5a00;
  border-radius: 6px;
  min-height: 36px;
  padding: 4px 10px;
  cursor: pointer;
  flex-shrink: 0;
  font-weight: 600;
}

.reset-button:hover {
  background: #ffe8bf;
}

input, select, textarea, button {
  font: inherit;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  padding: 8px 10px;
}

/* 16px minimum on real form fields: below that, iOS Safari zooms the whole
   page in on focus (reads as "this field is broken"), and Android renders
   the native <select> popup at whatever font-size the element has, so a
   smaller inherited size shows up as tiny option text. */
input, select, textarea {
  font-size: 16px;
  max-width: 100%;
  background: var(--color-surface);
  color: var(--color-text);
}

select {
  text-overflow: ellipsis;
}

/* Buttons get a distinct accent-tinted look so they read as actions, not as
   more input fields — plain inputs/selects share the same white background,
   so an unstyled button was easy to mistake for another field. */
button {
  cursor: pointer;
  background: #eef2ff;
  border-color: var(--color-accent);
  color: var(--color-accent);
  font-weight: 600;
}

button:hover:not(:disabled) {
  background: #dee6ff;
}

button:disabled {
  background: #f0f0f2;
  border-color: var(--color-border);
  color: var(--color-muted);
  cursor: not-allowed;
}

.contact-form .field {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.contact-form input, .contact-form textarea {
  width: 100%;
}

.honeypot {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.submit-status {
  min-height: 1.4em;
  margin-bottom: 8px;
}

.submit-button {
  width: 100%;
  min-height: 48px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  font-size: 1.05rem;
  font-weight: 600;
}

.submit-button:disabled {
  background: #a9b6e0;
  cursor: not-allowed;
}

:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .group-controls-row {
    flex-direction: column;
    align-items: stretch;
  }

  .row-fields,
  .row-actions {
    width: 100%;
  }

  .row-actions button {
    flex: 1;
  }

  .file-card-fields {
    flex-direction: column;
    align-items: stretch;
  }

  .file-card-fields > div {
    width: 100%;
  }

  .material-control {
    display: flex;
  }

  .material-control select,
  .material-custom-input {
    flex: 1;
    min-width: 0;
  }
}
