:root {
  --color-bg: #f5f5f8;
  --color-surface: #ffffff;
  --color-border: #e0e0e8;
  --color-border-focus: #5b5bd6;
  --color-text: #1a1a2e;
  --color-text-muted: #6b6b80;
  --color-required: #dc2626;
  --color-error: #dc2626;
  --color-success-bg: #f0fdf4;
  --color-success-border: #86efac;
  --color-success-text: #15803d;
  --color-error-bg: #fef2f2;
  --color-error-border: #fca5a5;
  --color-primary: #5b5bd6;
  --color-primary-hover: #4a4abf;
  --color-warn: #d97706;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  padding: 2.5rem 1rem 4rem;
}

.container {
  max-width: 640px;
  margin: 0 auto;
}

/* Header */

header {
  margin-bottom: 1.75rem;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.375rem;
}

header p {
  color: var(--color-text-muted);
  font-size: 0.9375rem;
}

/* Form card */

form {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Fields */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

label {
  font-size: 0.9375rem;
  font-weight: 600;
}

.required {
  color: var(--color-required);
}

.helper {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  line-height: 1.45;
}

.helper code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  background: #f0f0f6;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  font-size: 0.875em;
}

/* Inputs */

input[type="text"],
input[type="email"],
input[type="url"],
textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.9375rem;
  color: var(--color-text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(91, 91, 214, 0.1);
}

input.invalid,
textarea.invalid {
  border-color: var(--color-error);
}

input.invalid:focus,
textarea.invalid:focus {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

input[readonly] {
  background: #f5f5f8;
  color: var(--color-text-muted);
  cursor: default;
}

textarea {
  resize: vertical;
  min-height: 96px;
}

/* Char counters */

.char-counter {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-align: right;
  margin-top: 0.125rem;
}

.char-counter.warn { color: var(--color-warn); }
.char-counter.over { color: var(--color-error); font-weight: 600; }

/* Checkbox */

.field--checkbox {
  gap: 0.4rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9375rem;
}

.checkbox-label input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: var(--color-primary);
  flex-shrink: 0;
}

/* Readonly field */

.field--readonly label {
  color: var(--color-text-muted);
  font-weight: 500;
}

/* Error messages */

.error-message {
  font-size: 0.8125rem;
  color: var(--color-error);
  min-height: 1rem;
  line-height: 1.4;
}

.error-message:empty {
  display: none;
}

/* Submit button */

.form-footer {
  padding-top: 0.25rem;
}

button[type="submit"] {
  width: 100%;
  padding: 0.75rem 1.5rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

button[type="submit"]:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

button[type="submit"]:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Alerts */

.alert {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.alert--success {
  background: var(--color-success-bg);
  border: 1px solid var(--color-success-border);
  color: var(--color-success-text);
}

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

.alert--error a {
  color: inherit;
}
