:root {
  --bg: #f2f4f8;
  --bg-accent: #e6ebf5;
  --surface: #ffffff;
  --text: #16191f;
  --text-muted: #5c6472;
  --text-subtle: #838c9b;
  --border: #dde1e8;
  --border-strong: #c6ccd6;
  --field-bg: #fbfcfd;
  --accent: #4f57e3;
  --accent-hover: #4048cc;
  --accent-ring: rgba(79, 87, 227, 0.18);
  --accent-soft: rgba(79, 87, 227, 0.06);
  --success-bg: #e7f6ec;
  --success-text: #16653a;
  --success-border: #58b57c;
  --error-bg: #fdeceb;
  --error-text: #a52019;
  --error-border: #e0655c;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px -6px rgba(16, 24, 40, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141a;
    --bg-accent: #191c24;
    --surface: #1c1f27;
    --text: #eef0f4;
    --text-muted: #a3abba;
    --text-subtle: #7d8595;
    --border: #2c313c;
    --border-strong: #3b4250;
    --field-bg: #23272f;
    --accent: #8189ff;
    --accent-hover: #959cff;
    --accent-ring: rgba(129, 137, 255, 0.24);
    --accent-soft: rgba(129, 137, 255, 0.1);
    --success-bg: #12301f;
    --success-text: #8ee0aa;
    --success-border: #2f7148;
    --error-bg: #351917;
    --error-text: #ffaba4;
    --error-border: #8d3630;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -8px rgba(0, 0, 0, 0.55);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 2.5rem 1.25rem;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(ellipse 80% 60% at 50% -10%, var(--bg-accent), transparent 70%);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  -webkit-font-smoothing: antialiased;
}

.card {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}

@media (max-width: 520px) {
  body {
    padding: 1.25rem 0.85rem;
  }

  .card {
    padding: 1.5rem 1.25rem;
  }
}

.card-header {
  margin-bottom: 1.75rem;
}

h1 {
  margin: 0 0 0.4rem;
  font-size: 1.55rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.94rem;
}

form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

/* Fields share a row when there is room. auto-fit collapses the empty track, so
   a single field stretches to full width without needing a separate rule. */
.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.1rem;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.label-note {
  margin-left: 0.15rem;
  font-weight: 450;
  font-size: 0.8rem;
  color: var(--text-subtle);
}

input[type='text'],
input[type='email'],
textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--field-bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

input[type='text']:hover,
input[type='email']:hover,
textarea:hover {
  border-color: var(--text-subtle);
}

input[type='text']:focus,
input[type='email']:focus,
textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

textarea {
  resize: vertical;
  min-height: 7rem;
}

/* Only flag fields the user has actually interacted with. */
input:user-invalid,
textarea:user-invalid {
  border-color: var(--error-border);
}

input:user-invalid:focus,
textarea:user-invalid:focus {
  box-shadow: 0 0 0 3px rgba(224, 101, 92, 0.18);
}

/* File picker: the real input sits invisibly over the styled drop zone so
   clicking, keyboard focus and native drag-and-drop all keep working. */
.file-field {
  position: relative;
}

.file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 1.4rem 1rem;
  text-align: center;
  font-weight: 450;
  color: var(--text-muted);
  background: var(--field-bg);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.file-input:hover + .file-drop {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-input:focus-visible + .file-drop {
  border-color: var(--accent);
  border-style: solid;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.file-icon {
  width: 1.4rem;
  height: 1.4rem;
  fill: none;
  stroke: var(--text-subtle);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.file-drop-text {
  font-size: 0.9rem;
}

.file-drop-text strong {
  font-weight: 600;
  color: var(--accent);
}

.file-drop-limit {
  font-size: 0.78rem;
  color: var(--text-subtle);
}

.file-selected {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0.15rem 0 0;
  padding: 0;
  list-style: none;
}

.file-selected[hidden] {
  display: none;
}

.file-selected li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.45rem 0.65rem;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--accent-soft);
  border-radius: 8px;
}

.file-selected li.is-too-large {
  background: var(--error-bg);
  color: var(--error-text);
}

.file-selected-name {
  min-width: 0;
  word-break: break-all;
}

.file-selected-size {
  flex-shrink: 0;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
}

.file-selected li.is-too-large .file-selected-size {
  color: inherit;
}

/* Upload progress. Revealed by script.js only while bytes are in flight. */
.upload-progress {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.upload-progress[hidden] {
  display: none;
}

.upload-progress-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.upload-progress-percent {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.upload-progress progress {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 7px;
  border: none;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.upload-progress progress::-webkit-progress-bar {
  background: var(--border);
  border-radius: 999px;
}

.upload-progress progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.15s ease;
}

.upload-progress progress::-moz-progress-bar {
  background: var(--accent);
  border-radius: 999px;
}

.submit-btn {
  margin-top: 0.4rem;
  padding: 0.8rem 1rem;
  font: inherit;
  font-size: 0.97rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.submit-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.submit-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.submit-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.submit-btn:disabled {
  opacity: 0.62;
  cursor: progress;
}

.status {
  display: none;
  margin-top: 1.15rem;
  padding: 0.75rem 0.9rem;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
}

.status.success,
.status.error {
  display: block;
}

.status.success {
  background: var(--success-bg);
  color: var(--success-text);
  border-left-color: var(--success-border);
}

.status.error {
  background: var(--error-bg);
  color: var(--error-text);
  border-left-color: var(--error-border);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }

  .submit-btn:active:not(:disabled) {
    transform: none;
  }
}
