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

:root {
  --blue: #1a73e8;
  --green: #34a853;
  --red: #ea4335;
  --text: #202124;
  --text-secondary: #5f6368;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: #f8f9fa;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

#app {
  height: 100dvh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Screens */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  width: 100%;
  padding: 32px 24px;
  text-align: center;
}

.screen.active {
  display: flex;
}

/* Instruction text */
.instruction {
  font-size: 1.2rem;
  color: var(--text-secondary);
  max-width: 280px;
  line-height: 1.5;
}

/* Main capture button */
#capture-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: min(72vw, 280px);
  height: min(72vw, 280px);
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(26, 115, 232, 0.4);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  -webkit-user-select: none;
  user-select: none;
}

#capture-btn:active {
  transform: scale(0.95);
  box-shadow: 0 4px 16px rgba(26, 115, 232, 0.3);
}

#capture-btn svg {
  width: 40%;
  height: 40%;
}

#capture-btn span {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Hide the file input visually */
#camera-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Status text */
.status-text {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
}

/* Icon circles */
.icon-wrap {
  width: min(60vw, 220px);
  height: min(60vw, 220px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-wrap.success {
  background: var(--green);
  color: #fff;
}

.icon-wrap.error {
  background: var(--red);
  color: #fff;
}

.icon-wrap svg {
  width: 55%;
  height: 55%;
  stroke-width: 2.5;
}

/* Error detail */
.error-detail {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 280px;
  line-height: 1.4;
}

/* Secondary button */
.secondary-btn {
  padding: 16px 48px;
  border-radius: 32px;
  border: 2px solid var(--blue);
  background: transparent;
  color: var(--blue);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.secondary-btn:active {
  background: var(--blue);
  color: #fff;
}

/* Settings button */
#settings-btn {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: #e8eaed;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
}

#settings-btn:active {
  background: #dadce0;
}

#settings-btn svg {
  width: 22px;
  height: 22px;
}

/* Config screen */
.config-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
}

.config-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 360px;
  text-align: left;
}

.config-form label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 8px;
}

.config-form input,
.config-form textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #dadce0;
  border-radius: 12px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  resize: none;
  transition: border-color 0.15s ease;
}

.config-form input:focus,
.config-form textarea:focus {
  border-color: var(--blue);
}

#save-btn {
  width: 100%;
  max-width: 360px;
  padding: 16px;
  border-radius: 32px;
  border: none;
  background: var(--blue);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

#save-btn:active {
  opacity: 0.85;
}

/* Spinner */
.spinner {
  width: min(60vw, 220px);
  height: min(60vw, 220px);
  border-radius: 50%;
  border: 8px solid #e0e0e0;
  border-top-color: var(--blue);
  animation: spin 0.9s linear infinite;
}

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