:root {
  --primary: #0b5cff;
  --primary-dark: #0646c7;
  --surface: #ffffff;
  --background: #f3f6fb;
  --text: #172033;
  --muted: #6c768a;
  --border: #dce3ee;
  --success: #087f5b;
  --danger: #c92a2a;
  --shadow: 0 12px 34px rgba(31, 49, 82, 0.10);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(11,92,255,.12), transparent 34rem),
    var(--background);
  min-height: 100vh;
}

button, input, textarea, select { font: inherit; }

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 4px 22px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: white;
  font-weight: 800;
  box-shadow: var(--shadow);
}

h1 { margin: 0; font-size: clamp(1.25rem, 5vw, 1.75rem); }
.app-header p { margin: 4px 0 0; color: var(--muted); font-size: .92rem; }

.card {
  background: var(--surface);
  border: 1px solid rgba(220,227,238,.9);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.field-group { margin-bottom: 18px; }
.field-group > label:first-child {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.required, .optional {
  margin-left: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: .7rem;
}
.required { color: #fff; background: #e03131; }
.optional { color: var(--muted); background: #eef2f7; }

.photo-box {
  position: relative;
  min-height: 180px;
  border: 2px dashed #9cb7e7;
  border-radius: 18px;
  overflow: hidden;
  display: grid;
  place-items: center;
  text-align: center;
  cursor: pointer;
  background: #f7faff;
}
.photo-box.secondary { min-height: 130px; }
.photo-box input { position: absolute; opacity: 0; pointer-events: none; }
.photo-box img {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  background: #eef2f7;
}
.photo-box strong { display: block; color: var(--primary); font-size: 1.05rem; }
.photo-box small { display: block; margin-top: 6px; color: var(--muted); }

.file-meta { margin-top: 6px; color: var(--muted); font-size: .78rem; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

input[type="text"], input[type="date"], textarea, select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #fff;
  padding: 13px 14px;
  color: var(--text);
  outline: none;
  transition: .15s ease;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(11,92,255,.11);
}
textarea { resize: vertical; }

.primary-button, .secondary-button {
  border: 0;
  border-radius: 14px;
  min-height: 52px;
  padding: 12px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 800;
  cursor: pointer;
}
.primary-button {
  width: 100%;
  background: var(--primary);
  color: #fff;
}
.primary-button:hover { background: var(--primary-dark); }
.primary-button:disabled { opacity: .65; cursor: wait; }
.primary-button.compact, .secondary-button { width: auto; }
.secondary-button { color: var(--primary); background: #edf3ff; }

.spinner {
  width: 19px;
  height: 19px;
  border: 2px solid rgba(255,255,255,.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.message {
  border-radius: 12px;
  padding: 12px 14px;
  margin: 0 0 16px;
  font-size: .9rem;
}
.message.error { color: var(--danger); background: #fff1f1; }
.message.success { color: var(--success); background: #eafaf4; }

.result-card { margin-top: 16px; }
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.result-header h2 { margin: 0; }
.status-pill {
  color: var(--success);
  background: #eafaf4;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: .7rem;
  font-weight: 800;
}
.result-card dl {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px 14px;
  margin: 20px 0;
}
.result-card dt { color: var(--muted); }
.result-card dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }

footer {
  padding: 18px 4px 0;
  color: var(--muted);
  text-align: center;
  font-size: .78rem;
}

@media (max-width: 560px) {
  .app-shell { padding-left: 12px; padding-right: 12px; }
  .card { padding: 16px; border-radius: 18px; }
  .grid { grid-template-columns: 1fr; gap: 0; }
  .result-card dl { grid-template-columns: 1fr; gap: 4px; }
  .result-card dd { margin-bottom: 9px; }
  .button-row > * { width: 100% !important; }
}
