/* ─────────────────────────────────────────────
   Presoft · General form
   Apple-style grouped inset layout, light + dark
   ───────────────────────────────────────────── */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-hover: #fafafa;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #aeaeb2;
  --hairline: rgba(60, 60, 67, 0.16);
  --accent: #f39226;           /* Presoft orange */
  --accent-press: #e0821a;
  --accent-soft: rgba(243, 146, 38, 0.12);
  --danger: #ff3b30;
  --success: #34c759;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.04);
  --radius: 14px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-hover: #232325;
    --text: #f5f5f7;
    --text-2: #98989d;
    --text-3: #636366;
    --hairline: rgba(84, 84, 88, 0.55);
    --accent: #ff9f2e;
    --accent-press: #f39226;
    --accent-soft: rgba(255, 159, 46, 0.16);
    --danger: #ff453a;
    --success: #30d158;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", "Segoe UI", Inter, Roboto, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.35;
  letter-spacing: -0.012em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
svg .fill { fill: currentColor; stroke: none; }

/* ── Layout ── */
.stage {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(48px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.card {
  width: 100%;
  max-width: 440px;
}

.view { animation: rise 0.6s var(--ease) both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

/* ── Header ── */
.head { text-align: center; margin-bottom: 32px; }

.mark {
  display: block;
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  padding: 10px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow), inset 0 0 0 0.5px var(--hairline);
}

h1, h2 {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", "Segoe UI", Inter, sans-serif;
  font-weight: 700;
  letter-spacing: -0.03em;
}

h1 { font-size: 40px; line-height: 1.08; }
h2 { font-size: 32px; line-height: 1.1; }

.sub {
  margin: 8px 0 0;
  color: var(--text-2);
  font-size: 17px;
}

/* ── Grouped inset rows ── */
.group {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
}

.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  padding: 0 16px;
  cursor: text;
  transition: background-color 0.2s;
}

.row + .row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 52px;              /* inset past the icon, like iOS */
  right: 0;
  height: 0.5px;
  background: var(--hairline);
}

.row:hover { background: var(--surface-hover); }

.ico {
  flex: none;
  width: 22px;
  height: 22px;
  color: var(--text-3);
  transition: color 0.2s, transform 0.3s var(--ease);
}

.row:focus-within .ico { color: var(--accent); transform: scale(1.06); }

.row input {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  letter-spacing: inherit;
}

.row input::placeholder { color: var(--text-3); opacity: 1; }

/* Hide the native datalist arrow */
.row input::-webkit-calendar-picker-indicator { opacity: 0; }

/* Required marker: a small dot that disappears once filled */
.req {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.85;
  transition: opacity 0.2s, transform 0.3s var(--ease);
}

.row.filled .req { opacity: 0; transform: scale(0.2); }

/* Invalid state */
.row.invalid .ico { color: var(--danger); }
.row.invalid .req { background: var(--danger); opacity: 1; }
.row.invalid { animation: shake 0.4s var(--ease); }

@keyframes shake {
  0%, 100% { transform: none; }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

/* ── Platform chips ── */
.found {
  margin: 28px 0 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.found legend {
  padding: 0 4px;
  margin-bottom: 10px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.chip {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 72px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow), inset 0 0 0 0.5px var(--hairline);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s, background-color 0.2s, box-shadow 0.2s, transform 0.25s var(--ease);
}

.chip svg { width: 24px; height: 24px; }

.chip input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.chip:hover { color: var(--text); }
.chip:active { transform: scale(0.96); }

.chip:has(input:checked) {
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.chip:has(input:focus-visible) { outline: 3px solid var(--accent-soft); outline-offset: 2px; }

/* ── Submit ── */
.submit {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 54px;
  margin-top: 28px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s, transform 0.25s var(--ease), opacity 0.2s;
}

.submit:hover { background: var(--accent-press); }
.submit:active { transform: scale(0.98); }
.submit:focus-visible { outline: 4px solid var(--accent-soft); outline-offset: 2px; }

.submit .arrow { width: 20px; height: 20px; transition: transform 0.3s var(--ease); }
.submit:hover .arrow { transform: translateX(3px); }

.spinner {
  display: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

.submit.loading { pointer-events: none; opacity: 0.85; }
.submit.loading .label,
.submit.loading .arrow { display: none; }
.submit.loading .spinner { display: block; }

@keyframes spin { to { transform: rotate(360deg); } }

.error {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 14px 0 0;
  color: var(--danger);
  font-size: 14px;
  text-align: center;
}

.error[hidden] { display: none; }
.error svg { flex: none; width: 16px; height: 16px; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* ── Success ── */
.view-done { text-align: center; padding: 24px 0; }

.done-badge {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  margin: 0 auto 24px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  animation: pop 0.6s var(--ease) both;
}

.done-badge svg {
  width: 44px;
  height: 44px;
  stroke-width: 2.6;
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  animation: draw 0.45s 0.25s ease-out forwards;
}

@keyframes pop {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); }
}

@keyframes draw { to { stroke-dashoffset: 0; } }

.ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 32px;
  padding: 10px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.ghost:hover { background: var(--accent-soft); }
.ghost svg { width: 18px; height: 18px; }

/* ── Footer ── */
.foot {
  margin-top: 40px;
  color: var(--text-3);
  font-size: 12px;
}

/* ── Small screens ── */
@media (max-width: 380px) {
  h1 { font-size: 34px; }
  .chip { height: 66px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .done-badge svg { stroke-dashoffset: 0; }
}
